I have to order a selection by CONVERT(`codExtern`, SIGNED) with codeIgniter.
If I use it like this:
$this->db->order_by(" CONVERT(`codExtern`, SIGNED) ");
the codeigniter puts the SIGNED word between `-s, like:
CONVERT(codExtern, `INTEGER` )
How can I make it work?
Unfortunately you can’t disable identifier protection with parameters like in the
select()method. CI will call CI_DB_driver::_protect_identifiers on the input if it has a,in it.Currently you can workaround this if you set the supposedly “private” property
$_protect_identifierstofalseon your$this->dbbefore calling theorder_bymethod so when it runs it will skip this, and then flip it back (it helps with problematic column/table names for example). This is probably not a really good idea, in future CI versions this property might became reallyprivateand your code will break.Unfortunately the database library cannot be extended, but if you are not afraid of modifying the files under
systemyou can create an exception in theorder_by()method just like the “order by random()” got one.