Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Order_by problem.
  • Hi, i'm trying to use the order_by method.
    My code:

    $data['news'] = Model_News::find('all')->order_by('created_at','desc');

    And that show me this:
    "ErrorException [ Error ]: Call to a member function order_by() on a non-object"

    Somebody can help me? Thanks.


  • I remember a post by Harro recently in which he said that find might return null. Are you sure you're getting data without the order by clause?
  • HarroHarro
    Accepted Answer
    This is a find('all'). An 'all' query runs a get(), and that always returns an array.

    Issue here is that a find() executes, and therefore returns a result. So you can not chain any methods on it.

    Either use find() and the option array to pass any additional clauses, or use query() and chain the clause methods to it...

Howdy, Stranger!

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

In this Discussion