[eluser]Ricardo SDL[/eluser]
Hello fellows! I'm trying to execute a query like this using the codeigniter database class:
Code:
$ci->db->select('engine_types.*, cast(engine_types.name as decimal(5,1)) as name_numeric');
$ci->db->order_by('name_numeric', 'asc');
$query = $ci->db->get_where('engine_types', array('id_vehicle_type' => $id_vehicle_type));
But I'm receiving this error message:
A Database Error Occurred
Error Number: 1064
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 '`1))` as name_numeric FROM (`engine_types`) WHERE `id_vehicle_type` = 2 ORDER BY' at line 1
SELECT `engine_types`.*, cast(engine_types.name as decimal(5, `1))` as name_numeric FROM (`engine_types`) WHERE `id_vehicle_type` = 2 ORDER BY `engine_types`.`name_numeric` asc
The query executes correctly in phpmyadmin. The mysql version is 5.0.67-0ubuntu6 and the CI version is 1.7.2. Any idea of what is wrong?
Thanks in advance!