public function load($type, $id)
{
$bean = $this->dispense($type);
if (isset($this->stash[$this->nesting][$id])) {
$row = $this->stash[$this->nesting][$id];
} else {
try {
$rows = $this->writer->queryRecord($type, array('id' => array($id)));
} catch (SQLException $exception) {
if ($this->writer->sqlStateIn($exception->getSQLState(), array(QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN, QueryWriter::C_SQLSTATE_NO_SUCH_TABLE))) {
throw $exception;
//only throw if frozen
}
}
if (empty($rows)) {
return $bean;
}
$row = array_pop($rows);
}
$bean->importRow($row);
$this->nesting++;
$this->oodb->signal('open', $bean);
$this->nesting--;
return $bean->setMeta('tainted', FALSE);
}