I've installed codeigniter with sparks, along with php-activerecord spark as instructed on getsparks.org
I've made model Item for Items data table
<?php
Class Item extends ActiveRecord\Model {
}
and when I use
Item::all(array('conditions' => array('status = 0')))
everything goes fine, I'm getting all the items with status 0 via view (CI) (or via var_dump ).
By Using
Item::table()->last_sql;
gives me
SELECT * FROM `items` WHERE status = 0
but when I use
Item::find_by_status(0);
Item::table()->last_sql;
gives me
SELECT * FROM `items` WHERE `status`=? LIMIT 0,1
And I'm getting and error "Trying to get property of non-object"
Additional info:
table has this fiels:
id (int 11) primary key
name (varchar 15)
status (tiny int 1)
I'm using PHP version is 5.3.1
This solves the problem:
using find_all_by_statys(0) instead of find_by_statys(0) because it returns many results instead of only one.