コード例 #1
0
 /**
  * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
  * @return int
  * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException
  */
 protected function getObjectCountByQueryTYPO361(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query)
 {
     $statement = $query->getStatement();
     if ($statement instanceof \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement) {
         /*
          * Overriding default extbase logic for manually passed SQL
          */
         $sql = $statement->getStatement();
         $parameters = $statement->getBoundVariables();
         $this->replacePlaceholders($sql, $parameters);
         $sqlParser = \EssentialDots\ExtbaseHijax\Persistence\Parser\SQL::ParseString($sql);
         $countQuery = $sqlParser->getCountQuery();
         $result = $this->databaseHandle->sql_query($countQuery);
         $this->checkSqlErrors($countQuery);
         if (version_compare(TYPO3_version, '6.1.0', '<')) {
             $rows = $this->getRowsFromResult($query->getSource(), $result);
         } else {
             $rows = $this->getRowsFromResult($result);
         }
         $count = current(current($rows));
         $this->databaseHandle->sql_free_result($result);
     } else {
         /*
          * Default Extbase logic
          */
         $count = parent::getObjectCountByQuery($query);
     }
     return (int) $count;
 }
コード例 #2
0
 /**
  * Sets the statement of this query programmatically. If you use this, you will lose the abstraction from a concrete storage
  * backend (database).
  *
  * @param string $statement     The statement
  * @param array $parameters     An array of parameters. These will be bound to placeholders '?' in the $statement.
  * @return $this|\TYPO3\CMS\Extbase\Persistence\QueryInterface
  */
 public function statement($statement, array $parameters = array())
 {
     $this->parameters = $parameters;
     $this->sqlStatement = $statement;
     $this->sqlParser = \EssentialDots\ExtbaseHijax\Persistence\Parser\SQL::ParseString($statement);
     $this->statement = $this->qomFactory->statement($statement, $parameters);
     return $this;
 }