Elgg\Database::executeQuery PHP 메소드

executeQuery() 보호된 메소드

$query is executed via {@link Connection::query}. If there is an SQL error, a {@link DatabaseException} is thrown.
protected executeQuery ( string $query, Doctrine\DBAL\Connection $connection, array $params = [] ) : Doctrine\DBAL\Driver\Statement
$query string The query
$connection Doctrine\DBAL\Connection The DB connection
$params array Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve']
리턴 Doctrine\DBAL\Driver\Statement The result of the query
    protected function executeQuery($query, Connection $connection, array $params = [])
    {
        if ($query == null) {
            throw new \DatabaseException("Query cannot be null");
        }
        $this->query_count++;
        if ($this->timer) {
            $timer_key = preg_replace('~\\s+~', ' ', trim($query . '|' . serialize($params)));
            $this->timer->begin(['SQL', $timer_key]);
        }
        try {
            if ($params) {
                $value = $connection->executeQuery($query, $params);
            } else {
                // faster
                $value = $connection->query($query);
            }
        } catch (\Exception $e) {
            throw new \DatabaseException($e->getMessage() . "\n\n" . "QUERY: {$query} \n\n" . "PARAMS: " . print_r($params, true));
        }
        if ($this->timer) {
            $this->timer->end(['SQL', $timer_key]);
        }
        return $value;
    }