Weird backticks behaviour in Active Record in CodeIgniter 2.0.3

后端 未结 9 1597
迷失自我
迷失自我 2020-12-29 06:08

Previously my all queries were running fine in CI version 2.0 but when I upgraded to 2.0.3 some of my SELECT queries were broken.

CI is adding

9条回答
  •  爱一瞬间的悲伤
    2020-12-29 06:15

    All other answers are really old, this one works with CI 2.1.4

    // 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;
    

提交回复
热议问题