Stopping CodeIgniter from Escaping SQL
One night when I was getting exasperated with it tangling up my SQL expressions, I tweeted my frustration in the hope that I was just missing something simple. A prompt reply from @damiangostomski told me that this was indeed the case … I dug around for the API docs on codeigniter – it’s an established framework and has a good reputation. I knew it would have API docs even though I hadn’t used the framework before, and I found them:
$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.
That quote is from this API docs page – so a big thankyou to Damian for replying to me on twitter, and to the good people at codeigniter for adding a useful option to their framework and documenting it so nicely :)
I am truly glad you found the help you needed from the community. Wish you the best on your project.
What’s CASE?
Martin: Good question. CASE is an if/then/else for SQL statements, see the MySQL manual page for it: http://dev.mysql.com/doc/refman/5.0/en/case-statement.html Perhaps I should post some examples of using it as a blog entry one day
Thanks..
[code]$this->db->_protect_identifiers = FALSE;[/code]
also works, remember to set them back to true again
http://ellislab.com/forums/viewthread/130078/