I'm just trying to get data by find('first'),but it doesn't work.
This is code in controller.
$result = Model_questionstate::find('first');
This is model.
class Model_questionstate extends Model_Crud{
protected static $_table_name = 'questionstate';
protected static $_primary_key = 'id';
}
This shows
Fatal Error! ErrorException [ Fatal Error ]: Unsupported operand types COREPATH/classes/model/crud.php @ line 210
This doesn't show any error.
$result = Model_questionstate::find();
What is wrong with my codes?
You might want to use Model_questionstate::find_one_by()
.
It works by specifying a condition, and returns one record. I'm sure this fits your needs, since returning one row without any filtering is not a very common task.
By the way, Fuel doesn't support find('first')
in the Model_Crud (however it does in the Orm). Take a look at Model_Crud
's source if you're interested the insides.