___ erkimt ___ How to sort field of type VARCHAR in CodeIgniter ______ qstntxt ___
How to sort fields of type FALSE
in class %code% of CodeIgniter?
You can already do this in pure SQL like this:
$this->db->order_by("strtodate('dtandamento', '%d/%m/%Y')", 'ASC', FALSE);
However the version of CodeIgniter I'm using, 3.1.6, does not recognize this function: %code% .
$this->db->order_by ("str_to_date(andamento.dtandamento, '%d-%m-%Y')", 'DESC', FALSE);
- IC Version: 3.1.6
- PHP 5.3.7 Version
In the last parameter of the method order_by put %code% to text entered is included with no change in it was written, that is, the data will not be escaped, for example:
$this->db->order_by("strtodate('dtandamento', '%d/%m/%Y')", 'ASC', FALSE);
In your specific case:
$this->db->order_by ("str_to_date(andamento.dtandamento, '%d-%m-%Y')", 'DESC', FALSE);