OCA\Richdocuments\Db::getCollectionBy PHP 메소드

getCollectionBy() 공개 메소드

Get array of matching records
public getCollectionBy ( string $field, mixed $value ) : array
$field string for WHERE condition
$value mixed matching value(s)
리턴 array
    public function getCollectionBy($field, $value)
    {
        if (!is_array($value)) {
            $value = array($value);
        }
        $count = count($value);
        if ($count === 0) {
            return array();
        } elseif ($count === 1) {
            $result = $this->execute('SELECT * FROM ' . $this->tableName . ' WHERE `' . $field . '` =?', $value);
        } else {
            $stmt = $this->buildInQuery($field, $value);
            $result = $this->execute('SELECT * FROM ' . $this->tableName . ' WHERE ' . $stmt, $value);
        }
        $data = $result->fetchAll();
        if (!is_array($data)) {
            $data = array();
        }
        return $data;
    }