Illuminate\Database\Connection::select PHP Метод

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

Run a select statement against the database.
public select ( string $query, array $bindings = [], boolean $useReadPdo = true ) : array
$query string
$bindings array
$useReadPdo boolean
Результат array
    public function select($query, $bindings = [], $useReadPdo = true)
    {
        return $this->run($query, $bindings, function ($me, $query, $bindings) use($useReadPdo) {
            if ($me->pretending()) {
                return [];
            }
            // For select statements, we'll simply execute the query and return an array
            // of the database result set. Each element in the array will be a single
            // row from the database table, and will either be an array or objects.
            $statement = $this->getPdoForSelect($useReadPdo)->prepare($query);
            $me->bindValues($statement, $me->prepareBindings($bindings));
            $statement->execute();
            $fetchMode = $me->getFetchMode();
            $fetchArgument = $me->getFetchArgument();
            $fetchConstructorArgument = $me->getFetchConstructorArgument();
            if ($fetchMode === PDO::FETCH_CLASS && !isset($fetchArgument)) {
                $fetchArgument = 'StdClass';
                $fetchConstructorArgument = null;
            }
            return isset($fetchArgument) ? $statement->fetchAll($fetchMode, $fetchArgument, $fetchConstructorArgument) : $statement->fetchAll($fetchMode);
        });
    }

Usage Example

Пример #1
0
 /**
  * Run the query as a "select" statement against the connection.
  *
  * @return array
  */
 protected function runSelect()
 {
     if ($this->useWritePdo) {
         return $this->connection->select($this->toSql(), $this->getBindings(), false);
     }
     return $this->connection->select($this->toSql(), $this->getBindings());
 }
All Usage Examples Of Illuminate\Database\Connection::select