I've got a simple model:
class Model
{
public function find($name) {
return mysqli_query($con, 'select * from table where name = "'.$name.'"');
}
public function first($rows) {
foreach ($rows as $row) {
return $row;
}
}
}
I want to do something like this:
$model = new Model;
$model->find('test')->first();
But it's not working
Fatal error: Call to undefined method mysqli_result::first()
It works if I use $model->first($model->find('test'))
but it's really ugly. What should I change to achieve $model->find('test')->first()
calling?