Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Order_by problem.
arturfcouto
December 2012
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.
user00265
December 2012
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?
Harro
December 2012
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...
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
December 2012
user00265
December 2012