Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Order_by Database_Expression Model
  • Hi, I want to order-by a find on a Model with a Database_Expression
    I've seen the post "order_by random" ( and the issue ( It seems that it works with DB requests but not with Model requests. 1. DB::select('*')->from('table')->order_by(DB::expr('ISNULL(table.flied)'))->execute();
    2. Model_Table::find('all', array('order_by' => array(DB::expr('ISNULL(table.flied)') => 'ASC')));
    3. Model_Table::find()->order_by(DB::expr('ISNULL(table.flied)'), 'ASC')->get(); 1. work fine, 2. and 3. make Warning PHP and the sql have no ORDER BY Warning for 2.
    ErrorException [ Warning ]: Illegal offset type
    APPPATH/classes/controller/test.php @ line 23:
    23: Model_Table::find('all', array('order_by' => array(DB::expr('ISNULL(table.flied)') => 'ASC'))); Warning for 3.
    ErrorException [ Warning ]: Illegal offset type
    PKGPATH/orm/classes/query.php @ line 363:
    363: $this->order_by[$property] = $direction; Is there another way to do order-by with Database_Expression in Model that i have not seen ?
  • Seems to be a bug, if you you create an issue on Github I'll look into it.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion