how to order by with fuel_model

edited March 2018 in Modules
Hello,

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?

Comments

  • edited 5:39AM
    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 5:39AM
    Thank you Dernerserft, works perfectly.
Sign In or Register to comment.