Escape char when using SELECT and AS - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Escape char when using SELECT and AS (/showthread.php?tid=31603) |
Escape char when using SELECT and AS - El Forum - 06-25-2010 [eluser]Clooner[/eluser] I noticed that when using Code: $this->select('mytable.tablename AS table'); AR will generate Code: SELECT `mytable`.`tablename` AS table but should generate Code: SELECT `mytable`.`tablename` AS `table` A quick fix will be Code: $this->select('mytable.tablename AS `table`'); however a better solution will be to update the function _protect_identifiers in the db_driver.php file. Add this code: Code: // makes sure the alias get correct escape identifiers! directly after this: Code: // If the item has an alias declaration we remove it and set it aside. this way you will be able to write the code like this Code: $this->select('mytable.tablename AS table'); |