protected function queryInternal($fetchMethod, $fetchMode = null, $lazy = true)
    {
        $fetchMode = isset($fetchMode) ? $fetchMode : $this->fetchMode;
        list($profile, $rawSql) = $this->logQuery(__METHOD__);

        $self = $this;
        $execPromise = $this->internalExecute($this->sql, $this->params, $lazy);
        if ($execPromise instanceof LazyPromiseInterface) {
            return $execPromise->thenLazy(
                function($results) use ($fetchMethod, $fetchMode) {
                    return $this->fetchResults($results, $fetchMethod, $fetchMode);
                }
            );
        } else {
            $profileId = $profile ? \Reaction::$app->logger->profile('Query: ' . $rawSql) : null;
            return $execPromise->then(
                function($results) use ($self, $fetchMethod, $fetchMode) {
                    return $self->fetchResults($results, $fetchMethod, $fetchMode);
                }
            )->then(
                function($data) use ($profileId) {
                    \Reaction::profileEnd($profileId);
                    return $data;
                },
                function($error = null) use ($profileId) {
                    \Reaction::profileEnd($profileId);
                    return reject($error);
                }
            );
        }
    }
protected function queryInternal($fetchMethod, $fetchMode = null, $lazy = true)
    {
        $fetchMode = isset($fetchMode) ? $fetchMode : $this->fetchMode;
        list($profile, $rawSql) = $this->logQuery(__METHOD__);

        $self = $this;
        $execPromise = $this->internalExecute($this->sql, $this->params, $lazy);
        if ($execPromise instanceof LazyPromiseInterface) {
            return $execPromise->thenLazy(
                function($results) use ($fetchMethod, $fetchMode) {
                    return $this->fetchResults($results, $fetchMethod, $fetchMode);
                }
            );
        } else {
            $profileId = $profile ? \Reaction::$app->logger->profile('Query: ' . $rawSql) : null;
            return $execPromise->then(
                function($results) use ($self, $fetchMethod, $fetchMode) {
                    return $self->fetchResults($results, $fetchMethod, $fetchMode);
                }
            )->then(
                function($data) use ($profileId) {
                    \Reaction::profileEnd($profileId);
                    return $data;
                },
                function($error = null) use ($profileId) {
                    \Reaction::profileEnd($profileId);
                    return reject($error);
                }
            );
        }
    }
protected function queryInternal ( $ fetchMethod , $ fetchMode = null , $ lazy = true ) { $ fetchMode = isset ( $ fetchMode ) ? $ fetchMode : $ this -> fetchMode ; list ( $ profile , $ rawSql ) = $ this -> logQuery ( __METHOD__ ) ; $ self = $ this ; $ execPromise = $ this -> internalExecute ( $ this -> sql , $ this -> params , $ lazy ) ; if ( $ execPromise instanceof LazyPromiseInterface ) { return $ execPromise -> thenLazy ( function ( $ results ) use ( $ fetchMethod , $ fetchMode ) { return $ this -> fetchResults ( $ results , $ fetchMethod , $ fetchMode ) ; } ) ; } else { $ profileId = $ profile ? \ Reaction :: $ app -> logger -> profile ( 'Query: ' . $ rawSql ) : null ; return $ execPromise -> then ( function ( $ results ) use ( $ self , $ fetchMethod , $ fetchMode ) { return $ self -> fetchResults ( $ results , $ fetchMethod , $ fetchMode ) ; } ) -> then ( function ( $ data ) use ( $ profileId ) { \ Reaction :: profileEnd ( $ profileId ) ; return $ data ; } , function ( $ error = null ) use ( $ profileId ) { \ Reaction :: profileEnd ( $ profileId ) ; return reject ( $ error ) ; } ) ; } }
Performs the actual DB query of a SQL statement.
@param string $fetchMethod method of PDOStatement to be called
@param int    $fetchMode the result fetch mode. Please refer to [PHP manual](http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php)
for valid fetch modes. If this parameter is null, the value set in [[fetchMode]] will be used.
@param bool   $lazy Use LazyPromise
@return ExtendedPromiseInterface|LazyPromiseInterface with the method execution result
Performs the actual DB query of a SQL statement .