Welcome Guest, Not a member yet? Register   Sign In
CI 1.7 Database Changes for Select
#1

[eluser]philpalmieri[/eluser]
Hey guys,

Ever since i upgraded to 1.7 db selects with CONCATS arn't working because CI is escaping the quotes inside the concat.

so in 1.6.3 i could do

Code:
$this->db->select(id, CONCAT(first_name, ' ', last_name) as name);

but in 1.7 the same line bombs out.

i tried back ticking names, escaping the quotes, etc. but then it just adds more escaping. I've gone through and changed my scripts so that now i'm selecting both columns and then concatenating them after the select, but i just wanted to drop a line and see if this was done intentionally, or just a byproduct of something else being tweaked.
#2

[eluser]Phil_B[/eluser]
I've been running into this a lot as well. You can disable escaping with the second paramter:

Code:
$this->db->select('first, CONCAT(second, third) fourth', FALSE);

At least until it gets tweaked or fixed.
#3

[eluser]Phil_B[/eluser]
Also seems to be an issue with ORDER BY.
Code:
$this->db->order_by('first, second');

Results in:

Code:
SELECT * FROM (`table_name`) ORDER BY `first,` second


Edit:
Appending the sort order makes the query work but the second field is not escaped.
Code:
$this->db->order_by('first ASC, second DESC');
Code:
SELECT * FROM (`table_name`) ORDER BY `first` ASC, second DESC
#4

[eluser]philpalmieri[/eluser]
Thanks,

I've been using CI for a while and never noticed to the second param on the select.




Theme © iAndrew 2016 - Forum software by © MyBB