DB_active_rec.php, function: select(), issue: cannot use MySQL IF function (not construct) + more. - 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: DB_active_rec.php, function: select(), issue: cannot use MySQL IF function (not construct) + more. (/showthread.php?tid=6170) |
DB_active_rec.php, function: select(), issue: cannot use MySQL IF function (not construct) + more. - El Forum - 02-17-2008 [eluser]MPress[/eluser] You cannot use the MySQL IF function within the string argument for the select active-record function. This is because it tries to reconcile the values by exploding on a ','. Although, I somehow remember this not being an issue previously... Anyways, the IF function has the syntax of: IF({cond. is met}, {return this}, {otherwise this}). Update: As well, the new automatic backquote feature of AR functions fails on this kind of thing: FORMAT(something, 2) since we get FORMAT(`something`, `2`). 2 must be numeric and therefore cannot be enclosed in backquotes. Here is a temporary workaround for the first issue. Simply escape special commas by doubling up (',,'). Follow $comma_fix. Code: function select($select = '*', $protect_identifiers = TRUE, $comma_fix = FALSE) DB_active_rec.php, function: select(), issue: cannot use MySQL IF function (not construct) + more. - El Forum - 02-17-2008 [eluser]Seppo[/eluser] Have you tried passing $protect_identifiers = FALSE? DB_active_rec.php, function: select(), issue: cannot use MySQL IF function (not construct) + more. - El Forum - 02-17-2008 [eluser]Derek Allard[/eluser] Yes, I think this might just be a matter of needing Code: $this->db->select("query", FALSE); |