public function tryLoadAny(Model $m)
{
$load = $this->action($m, 'select');
$load->limit(1);
// execute action
try {
$data = $this->typecastLoadRow($m, $load->getRow());
} catch (\PDOException $e) {
throw new Exception(['Unable to load due to query error', 'query' => $load->getDebugQuery(false), 'model' => $m, 'conditions' => $m->conditions], null, $e);
}
if (!$data) {
return;
}
if (isset($data[$m->id_field])) {
$m->id = $data[$m->id_field];
} else {
throw new Exception(['ID of the record is unavailable. Read-only mode is not supported', 'model' => $m, 'data' => $data]);
}
return $data;
}