Doctrine\DBAL\Connection::query PHP Method

query() public method

Executes an SQL statement, returning a result set as a Statement object.
public query ( ) : Doctrine\DBAL\Driver\Statement
return Doctrine\DBAL\Driver\Statement
    public function query()
    {
        $this->connect();
        $args = func_get_args();
        $logger = $this->_config->getSQLLogger();
        if ($logger) {
            $logger->startQuery($args[0]);
        }
        try {
            $statement = $this->_conn->query(...$args);
        } catch (Exception $ex) {
            throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $args[0]);
        }
        $statement->setFetchMode($this->defaultFetchMode);
        if ($logger) {
            $logger->stopQuery();
        }
        return $statement;
    }

Usage Example

コード例 #1
0
ファイル: Product.php プロジェクト: AlexandrKozyr/oops_test
 /**
  * @return array|null
  */
 public function read()
 {
     if (is_null($this->stmt)) {
         $this->stmt = $this->connection->query("SELECT * FROM products");
     }
     return $this->stmt->fetch();
 }
All Usage Examples Of Doctrine\DBAL\Connection::query