ORDER BY FIELD – codeigniter 2.1.x

In codeigniter 2.1.3

// set this to false so that _protect_identifiers skips escaping:
$this->db->_protect_identifiers = FALSE;

// your order_by line:
$this -> db -> order_by('FIELD ( products.country_id, 2, 0, 1 )');

// important to set this back to TRUE or ALL of your queries from now on will be non-escaped:
$this->db->_protect_identifiers = TRUE;

I tried this in my app and its working fine.

ref: https://github.com/EllisLab/CodeIgniter/issues/1846