database query problem with escaping. - 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: database query problem with escaping. (/showthread.php?tid=46310) |
database query problem with escaping. - El Forum - 10-27-2011 [eluser]gloosemo[/eluser] I have the following query Code: $table1 = "consump"; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'asc' at line 5 SELECT consump.id as id, DATE_FORMAT(time, '%k:%i') AS formattime, CONCAT(food, ' (', brand, ')') AS concfood, ftype, name, CONCAT(c1, ' ', c2) AS consume, comb, cal, fat, sat, trans, chol, sod, carb, fib, sug, pro FROM (`consump`) JOIN `foodgroups` ON `consump`.`ftype` = `foodgroups`.`id` WHERE `date` = '2011-10-27' ORDER BY DATE_FORMAT(time, `%H)` asc It seems the active query is escaping the order_by clause in a very weird fashion placing a quote outside the brackets instead of inside where it should be, which is annoying because i need to DATE_FORMAT sql function. is there a way around this? Currently i'm accomplshing it manually without escaping anything which is dangerous... thanks, G |