Welcome Guest, Not a member yet? Register   Sign In
Active Records and comma char
#1

[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
#2

[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.
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB