protected function factory($row)
{
$mapper = clone $this;
$mapper->reset();
foreach ($row as $key => $val) {
if (array_key_exists($key, $this->fields)) {
$var = 'fields';
} elseif (array_key_exists($key, $this->adhoc)) {
$var = 'adhoc';
} else {
continue;
}
$mapper->{$var}[$key]['value'] = $val;
$mapper->{$var}[$key]['initial'] = $val;
if ($var == 'fields' && $mapper->{$var}[$key]['pkey']) {
$mapper->{$var}[$key]['previous'] = $val;
}
}
$mapper->query = [clone $mapper];
if (isset($mapper->trigger['load'])) {
\Base::instance()->call($mapper->trigger['load'], $mapper);
}
return $mapper;
}