/** * Load values into record * @param IRecord record * @param array value names */ public function loadValues(IRecord $record, $values = null) { try { $key = $record->getValues($this->getConfig()->getPrimaryColumns()); } catch (\MemberAccessException $e) { throw new \InvalidStateException("Key was not set.", null, $e); } $fluent = $this->createFindFluent(); if ($values !== null) { $fluent->select(false)->select($values); } $fluent->where($key); try { $row = $fluent->fetch(); } catch (\DibiDriverException $e) { throw new \ModelException("Unknown columns. " . $e->getMessage(), $e->getCode(), $e); } foreach ($row as $key => $val) { $record->{$key} = $val; } }