Advertisement
Guest User

Untitled

a guest
Mar 27th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. <?php
  2. /** Repository */
  3. $query = $this->createQuery();
  4. $sqlParts = $this->queryParser->parseQuery($query);
  5. $query->statement($sqlParts, array());
  6. return $query->execute();
  7. ?>
  8.  
  9. Execute at some points end up being in the core function:
  10.  
  11. <?php
  12. /**
  13.  * Returns the object data using a custom statement
  14.  *
  15.  * @param Statement $statement
  16.  * @return array
  17.  */
  18. protected function getObjectDataByRawQuery(Statement $statement) {
  19.     $realStatement = $statement->getStatement();
  20.     $parameters = $statement->getBoundVariables();
  21.  
  22.     if ($realStatement instanceof \TYPO3\CMS\Core\Database\PreparedStatement) {
  23.         $realStatement->execute($parameters);
  24.         $rows = $realStatement->fetchAll();
  25.  
  26.         $realStatement->free();
  27.     } else {
  28.         /**
  29.     This is the part where the query is executed. The only problem is, that $realStatement->getStatement() returns an array.
  30. This is then used to call $this->databaseHandle->sql_query, which expects a SQL string.
  31. Obviously the $result is gonna be NULL, as sql_query cannot handle the given array.
  32. In the end the core will fail at the following function:
  33.  
  34. Fatal error: Call to a member function fetch_assoc() on a non-object in /~/typo3_src/typo3/sysext/core/Classes/Database/DatabaseConnection.php on line 1044
  35.         */
  36.  
  37.         /**
  38.          * @deprecated since 6.2, this block will be removed in two versions
  39.          * the deprecation log is in Qom\Statement
  40.          */
  41.         if (!empty($parameters)) {
  42.             $this->replacePlaceholders($realStatement, $parameters);
  43.         }
  44.  
  45.         $result = $this->databaseHandle->sql_query($realStatement);
  46.  
  47.         $this->checkSqlErrors();
  48.  
  49.         $rows = array();
  50.         while ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
  51.             if (is_array($row)) {
  52.                 $rows[] = $row;
  53.             }
  54.         }
  55.         $this->databaseHandle->sql_free_result($result);
  56.     }
  57.  
  58.     return $rows;
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement