CodeIgniter Forums
Using MySQL find_in_set with activerecord order_by - 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: Using MySQL find_in_set with activerecord order_by (/showthread.php?tid=45358)



Using MySQL find_in_set with activerecord order_by - El Forum - 09-18-2011

[eluser]Unknown[/eluser]
Hey there!

I already searched the forum and googled for it, but I didnt find anything.

The problem is when I try to use find_in_set in an order_by statement, it tries to escape my query, just like it happens in the SELECT, but when thats the case, you can use the "FALSE" parameter to make it work.

Does anybody know how to do that with the order_by?

The code:
$this->db->order_by('find_in_set(id_status, "3,1,2")')

The result:
ORDER BY find_in_set(id_status, `"3`, `1`, `2"` )

I even tried:
$this->db->order_by('find_in_set(id_status, "3,1,2")', FALSE)
AND
$this->db->order_by('find_in_set(id_status, "3,1,2")', 'ASC', FALSE)