Psecio\Gatekeeper\DataSource\Mysql::fetch PHP Метод

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

Fetch the data matching the results of the SQL operation
public fetch ( string $sql, array $data, boolean $single = false ) : array | boolean
$sql string SQL statement
$data array Data to use in fetch operation
$single boolean Only fetch a single record
Результат array | boolean Fetched data or boolean false on error
    public function fetch($sql, $data, $single = false)
    {
        $sth = $this->getDb()->prepare($sql);
        $result = $sth->execute($data);
        if ($result === false) {
            $error = $sth->errorInfo();
            $this->lastError = 'DB ERROR: [' . $sth->errorCode() . '] ' . $error[2];
            return false;
        }
        $results = $sth->fetchAll(\PDO::FETCH_ASSOC);
        return $single === true ? array_shift($results) : $results;
    }