I have a table with a 'title' field, I am trying to get all rows in this table, and order them by the title ASC. The four records I am testing with have the titles:
Another test
My New Page
NEW
aaa
This is also the order the rows are returned which is incorrect. 'aaa' should be at the top of the list. I assume the problem is with the lower and upper case characters.
I want to order by LOWER(title) rather then just title however I am having issues making this work in FuelPHP.
The code I'm using to select the records is:
$pages = Model_pages::find('all', array(
'order_by' => array('title' => 'asc')
));
I have tried the following code, all variations result in SQL or PHP errors:
$pages = Model_pages::find('all', array(
'order_by' => \DB::expr('LOWER(title) ASC')
));
$pages = Model_pages::find('all', array(
'order_by' => \DB::expr('LOWER(title)')
));
$pages = Model_pages::find('all', array(
'order_by' => \DB::expr('LOWER(title) ASC')
));
$pages = Model_pages::find('all', array(
'order_by' => array( \DB::expr('LOWER(title)') )
));
$pages = Model_pages::find('all', array(
'order_by' => array( \DB::expr('LOWER(title) ASC') )
));
$pages = Model_pages::find('all', array(
'order_by' => array( \DB::expr('LOWER(title)') => 'ASC' )
));
How do I make the code above order items regardless of their 'case'?
It looks like you're new here. If you want to get involved, click one of these buttons!