Weird backticks behaviour in Active Record in CodeIgniter 2.0.3

后端 未结 9 1556
迷失自我
迷失自我 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:31

    The solution is very simple: In the database configuration file (./application/config/database.php) add a new element to array with default settings.

    $db['default']['_protect_identifiers']= FALSE;
    

    This solution is working for me and more elegant and professional.

    0 讨论(0)
  • 2020-12-29 06:32

    I think you should check DB_driver.php file, there is a variable named as protect_identifier, the point is when you will check with older version of CI, you will see that there is a condition which is missing in new version,escape variable which is checked for nullability, paste that condition from older version and you will be OK

    0 讨论(0)
  • 2020-12-29 06:33

    CI_DB_active_record::where() has a third param for escaping, this has worked better for me than switching on and off CI_DB_driver::_protect_identifiers

    public function where($key, $value = NULL, $escape = TRUE)
    

    Not sure what CI version this was added in.

    HTH someone

    0 讨论(0)
提交回复
热议问题