public function loadBy($field, $value)
{
if (!is_array($value)) {
$value = array($value);
}
$result = $this->execute('SELECT * FROM ' . $this->tableName . ' WHERE `' . $field . '` =?', $value);
$data = $result->fetchAll();
if (!is_array($data) || !count($data)) {
$this->data = array();
} elseif (count($data) != 1) {
throw new Exception('Duplicate ' . $value . ' for the filed ' . $field);
} else {
$this->data = $data[0];
}
return $this;
}