isao otika Sun Jun 09 16:12:00 -0400 2013

Subject: Fatal error: Uncaught exception 'ActiveRecord\RecordNotFound'

Greetings , I am trying out active record. So far it seems to be great though it cant seem to get it work smoothly.
Some of the methods work but others don't
For example
$user=new user();
foreach(user::find('all') AS $row) {
echo "$row->username <br>"; //this works fine.
}

//howwever when options are supplied or validates_uniqueness_of is used. an exception is thrown
foreach (user::find('all','order'=>"created DESC ,'limit'=>10")) {
echo "$row->username <br>";
//this results in
/*Fatal error: Uncaught exception 'ActiveRecord\RecordNotFound' with message 'Couldn't find all user with IDs (all,created DESC ,'limit'=>10) (found 0, but was looking for 2)
*/
}

I am using php 5.3.4 and using nightly build (May 8 2013)
Please advise on how to fix this.


isao otika Mon Jun 10 08:43:44 -0400 2013

Solution

The find method was used wrongly.

user:find('all',array('order'=>"created DESC, 'imit'=>10"))

the first parameter expects the type of query and the second parameter should be an array containing options.

(1-1/1)