OCA\Richdocuments\Db::loadBy PHP Метод

loadBy() публичный Метод

Get single record matching condition
public loadBy ( string $field, mixed $value ) : Db
$field string for WHERE condition
$value mixed matching value(s)
Результат Db
    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;
    }