Hello everyone. I need to get single record from database as array. When I use the this code, error comes out "Fatal error: Cannot use object of type App\Entity\City as array in"
$city = \App\Entity\City::findFirst([
'conditions' => "id = :id:",
'bind' => [
'id' => $id,
],
'hydration' => \Phalcon\Mvc\Model\Resultset::HYDRATE_ARRAYS
]);
I found that findFirst method does not support hydration
Now I use the this code
$result = \App\Entity\City::find([
'conditions' => "id = :id:",
'bind' => [
'id' => $id,
],
'limit' => 1,
'hydration' => \Phalcon\Mvc\Model\Resultset::HYDRATE_ARRAYS
]);
$result->rewind();
$city = $result->current();
Is there a better alternative?