/**
  * Returns the object data using a custom statement
  *
  * @param Statement $statement
  * @return array
  */
 protected function getObjectDataByRawQuery(Statement $statement)
 {
     $realStatement = $statement->getStatement();
     $parameters = $statement->getBoundVariables();
     if ($realStatement instanceof \TYPO3\CMS\Core\Database\PreparedStatement) {
         $realStatement->execute($parameters);
         $rows = $realStatement->fetchAll();
         $realStatement->free();
     } else {
         /**
          * @deprecated since 6.2, this block will be removed in two versions
          * the deprecation log is in Qom\Statement
          */
         if (!empty($parameters)) {
             $this->replacePlaceholders($realStatement, $parameters);
         }
         $result = $this->databaseHandle->sql_query($realStatement);
         $this->checkSqlErrors();
         $rows = array();
         while ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
             if (is_array($row)) {
                 $rows[] = $row;
             }
         }
         $this->databaseHandle->sql_free_result($result);
     }
     return $rows;
 }
Exemplo n.º 2
0
 /**
  * Returns the object data using a custom statement
  *
  * @param Qom\Statement $statement
  * @return array
  */
 protected function getObjectDataByRawQuery(Qom\Statement $statement)
 {
     $realStatement = $statement->getStatement();
     $parameters = $statement->getBoundVariables();
     if ($realStatement instanceof \TYPO3\CMS\Core\Database\PreparedStatement) {
         $realStatement->execute($parameters);
         $rows = $realStatement->fetchAll();
         $realStatement->free();
     } else {
         $result = $this->databaseHandle->sql_query($realStatement);
         $this->checkSqlErrors();
         $rows = array();
         while ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
             if (is_array($row)) {
                 $rows[] = $row;
             }
         }
         $this->databaseHandle->sql_free_result($result);
     }
     return $rows;
 }
Exemplo n.º 3
0
 /**
  * Returns the object data using a custom statement
  *
  * @param Qom\Statement $statement
  * @return array
  * @throws SqlErrorException when the raw SQL statement fails in the database
  */
 protected function getObjectDataByRawQuery(Qom\Statement $statement)
 {
     $realStatement = $statement->getStatement();
     $parameters = $statement->getBoundVariables();
     // The real statement is an instance of the Doctrine DBAL QueryBuilder, so fetching
     // this directly is possible
     if ($realStatement instanceof QueryBuilder) {
         try {
             $result = $realStatement->execute();
         } catch (DBALException $e) {
             throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064721);
         }
         $rows = $result->fetchAll();
     } elseif ($realStatement instanceof \Doctrine\DBAL\Statement) {
         try {
             $result = $realStatement->execute($parameters);
         } catch (DBALException $e) {
             throw new SqlErrorException($e->getPrevious()->getMessage(), 1481281404);
         }
         $rows = $result->fetchAll();
     } elseif ($realStatement instanceof \TYPO3\CMS\Core\Database\PreparedStatement) {
         $realStatement->execute($parameters);
         $rows = $realStatement->fetchAll();
         $realStatement->free();
     } else {
         // Do a real raw query. This is very stupid, as it does not allow to use DBAL's real power if
         // several tables are on different databases, so this is used with caution and could be removed
         // in the future
         try {
             $connection = $this->connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
             $statement = $connection->executeQuery($realStatement);
         } catch (DBALException $e) {
             throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064775);
         }
         $rows = $statement->fetchAll();
     }
     return $rows;
 }