CodeIgniter Forums
Active Records and comma char - 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: Active Records and comma char (/showthread.php?tid=30532)



Active Records and comma char - El Forum - 05-18-2010

[eluser]Unknown[/eluser]
I've stumbled upon this error while building page listing query
Code:
$this->db->select("CONCAT('page,',alias,'.html') as link, name", FALSE);
$this->db->from('Pages');
the result is different from my expectations :
Code:
alias:page, start.html // notice the space char after comma
name:Start
I've managed to work it around using TRIM function as below:
Code:
$this->db->select("CONCAT(TRIM('page,'),alias,'.html') as link, name", FALSE);
but i believe that using FALSE as 2nd parameter should be equal to "DO NOT TOUCH MY SQL IN ANY WAY".
So here is my bug report

Regards, aln


Active Records and comma char - El Forum - 05-18-2010

[eluser]WanWizard[/eluser]
No, the manual states:
Quote: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.

This works, and is not the problem. The bug is that the code interprets the comma as a field separator. It splits the string to check for table names so it can add a table prefix. This breaks the CONCAT.


Active Records and comma char - El Forum - 05-25-2010

[eluser]Mark Croxton[/eluser]
See: http://codeigniter.com/bug_tracker/bug/8663/