Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

how to order by with fuel_model

edited March 2018 in Modules

I can't understand from the user guide how to order by a specific field with this:
$cheeses = fuel_model('cheeses')

I tried:
$cheeses = fuel_model('cheeses', array('order' => array('cheese_name' =>'asc')));
and this:
$cheeses = fuel_model('cheeses', ['order' => array('cheese_name' =>'asc')]);

I get this error:
Message: explode() expects parameter 2 to be string, array given

I tried this:
$cheeses = fuel_model('cheeses', '', ['order' => array('cheese_name' =>'asc')]);

No ordering is happening

Filename: database/DB_query_builder.php

Can you please help?


  • edited 9:50AM
    Try something like this: $cheeses = fuel_model('cheeses', array('find' => 'all', 'where' => array('post_date <' => date('Y-m-d H:i:s')), 'order' => 'post_date asc'));
  • edited 9:50AM
    Thank you Dernerserft, works perfectly.
Sign In or Register to comment.