lib/Doctrine/DBAL/Connection.php
public function executeQuery($query, array $params = [], $types = [], ?QueryCacheProfile $qcp = null)
    {
        if ($qcp !== null) {
            return $this->executeCacheQuery($query, $params, $types, $qcp);
        }

        $connection = $this->getWrappedConnection();

        $logger = $this->_config->getSQLLogger();
        if ($logger) {
            $logger->startQuery($query, $params, $types);
        }

        try {
            if ($params) {
                [$query, $params, $types] = SQLParserUtils::expandListParameters($query, $params, $types);

                $stmt = $connection->prepare($query);
                if ($types) {
                    $this->_bindTypedValues($stmt, $params, $types);
                    $stmt->execute();
                } else {
                    $stmt->execute($params);
                }
            } else {
                $stmt = $connection->query($query);
            }
        } catch (Throwable $ex) {
            throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $query, $this->resolveParams($params, $types));
        }

        $stmt->setFetchMode($this->defaultFetchMode);

        if ($logger) {
            $logger->stopQuery();
        }

        return $stmt;
    }
public function executeQuery($query, array $params = [], $types = [], ?QueryCacheProfile $qcp = null)
    {
        if ($qcp !== null) {
            return $this->executeCacheQuery($query, $params, $types, $qcp);
        }

        $connection = $this->getWrappedConnection();

        $logger = $this->_config->getSQLLogger();
        if ($logger) {
            $logger->startQuery($query, $params, $types);
        }

        try {
            if ($params) {
                [$query, $params, $types] = SQLParserUtils::expandListParameters($query, $params, $types);

                $stmt = $connection->prepare($query);
                if ($types) {
                    $this->_bindTypedValues($stmt, $params, $types);
                    $stmt->execute();
                } else {
                    $stmt->execute($params);
                }
            } else {
                $stmt = $connection->query($query);
            }
        } catch (Throwable $ex) {
            throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $query, $this->resolveParams($params, $types));
        }

        $stmt->setFetchMode($this->defaultFetchMode);

        if ($logger) {
            $logger->stopQuery();
        }

        return $stmt;
    }
public function executeQuery ( $ query , array $ params = [ ] , $ types = [ ] , ? QueryCacheProfile $ qcp = null ) { if ( $ qcp !== null ) { return $ this -> executeCacheQuery ( $ query , $ params , $ types , $ qcp ) ; } $ connection = $ this -> getWrappedConnection ( ) ; $ logger = $ this -> _config -> getSQLLogger ( ) ; if ( $ logger ) { $ logger -> startQuery ( $ query , $ params , $ types ) ; } try { if ( $ params ) { [ $ query , $ params , $ types ] = SQLParserUtils :: expandListParameters ( $ query , $ params , $ types ) ; $ stmt = $ connection -> prepare ( $ query ) ; if ( $ types ) { $ this -> _bindTypedValues ( $ stmt , $ params , $ types ) ; $ stmt -> execute ( ) ; } else { $ stmt -> execute ( $ params ) ; } } else { $ stmt = $ connection -> query ( $ query ) ; } } catch ( Throwable $ ex ) { throw DBALException :: driverExceptionDuringQuery ( $ this -> _driver , $ ex , $ query , $ this -> resolveParams ( $ params , $ types ) ) ; } $ stmt -> setFetchMode ( $ this -> defaultFetchMode ) ; if ( $ logger ) { $ logger -> stopQuery ( ) ; } return $ stmt ; }
Executes an, optionally parametrized, SQL query.

If the query is parametrized, a prepared statement is used.
If an SQLLogger is configured, the execution is logged.

@param string                 $query  The SQL query to execute.
@param mixed[]                $params The parameters to bind to the query, if any.
@param int[]|string[]         $types  The types the previous parameters are in.
@param QueryCacheProfile|null $qcp    The query cache profile, optional.

@return ResultStatement The executed statement.

@throws DBALException
Executes an optionally parametrized SQL query .