예제 #1
0
 /**
  * Parses the query and returns the SQL statement parts.
  *
  * @param QueryInterface $query The query
  * @return array The SQL statement parts
  */
 public function parseQuery(QueryInterface $query)
 {
     $sql = array();
     $sql['keywords'] = array();
     $sql['tables'] = array();
     $sql['unions'] = array();
     $sql['fields'] = array();
     $sql['where'] = array();
     $sql['additionalWhereClause'] = array();
     $sql['orderings'] = array();
     $sql['limit'] = (int) $query->getLimit() ?: NULL;
     $sql['offset'] = (int) $query->getOffset() ?: NULL;
     $source = $query->getSource();
     $this->parseSource($source, $sql);
     $this->parseConstraint($query->getConstraint(), $source, $sql);
     $this->parseOrderings($query->getOrderings(), $source, $sql);
     $tableNames = array_unique(array_keys($sql['tables'] + $sql['unions']));
     foreach ($tableNames as $tableName) {
         if (is_string($tableName) && !empty($tableName)) {
             $this->addAdditionalWhereClause($query->getQuerySettings(), $tableName, $sql);
         }
     }
     return $sql;
 }
예제 #2
0
 /**
  * Returns a ready to be executed QueryBuilder object, based on the query
  *
  * @param QueryInterface $query
  * @return QueryBuilder
  */
 public function convertQueryToDoctrineQueryBuilder(QueryInterface $query)
 {
     // Reset all properties
     $this->tablePropertyMap = [];
     $this->tableAliasMap = [];
     $this->unionTableAliasCache = [];
     $this->tableName = '';
     // Find the right table name
     $source = $query->getSource();
     $this->initializeQueryBuilder($source);
     $constraint = $query->getConstraint();
     if ($constraint instanceof Qom\ConstraintInterface) {
         $wherePredicates = $this->parseConstraint($constraint, $source);
         if (!empty($wherePredicates)) {
             $this->queryBuilder->andWhere($wherePredicates);
         }
     }
     $this->parseOrderings($query->getOrderings(), $source);
     $this->addTypo3Constraints($query);
     return $this->queryBuilder;
 }
예제 #3
0
 /**
  * Parses the query and returns the SQL statement parts.
  *
  * @param QueryInterface $query The query
  * @param array &$parameters
  * @return array The SQL statement parts
  */
 public function parseQuery(QueryInterface $query, array &$parameters)
 {
     $statementParts = array();
     $statementParts['keywords'] = array();
     $statementParts['tables'] = array();
     $statementParts['unions'] = array();
     $statementParts['fields'] = array();
     $statementParts['where'] = array();
     $statementParts['additionalWhereClause'] = array();
     $statementParts['orderings'] = array();
     $statementParts['limit'] = array();
     $source = $query->getSource();
     $this->parseSource($source, $statementParts);
     $this->parseConstraint($query->getConstraint(), $source, $statementParts, $parameters);
     $this->parseOrderings($query->getOrderings(), $source, $statementParts);
     $this->parseLimitAndOffset($query->getLimit(), $query->getOffset(), $statementParts);
     $tableNames = array_unique(array_keys($statementParts['tables'] + $statementParts['unions']));
     foreach ($tableNames as $tableNameOrAlias) {
         if (is_string($tableNameOrAlias) && strlen($tableNameOrAlias) > 0) {
             $this->addAdditionalWhereClause($query->getQuerySettings(), $tableNameOrAlias, $statementParts);
         }
     }
     return $statementParts;
 }
 /**
  * Parses the query and returns the SQL statement parts.
  *
  * @param QueryInterface $query The query
  * @return array The SQL statement parts
  */
 public function parseQuery(QueryInterface $query)
 {
     $this->tablePropertyMap = array();
     $sql = array();
     $sql['keywords'] = array();
     $sql['tables'] = array();
     $sql['unions'] = array();
     $sql['fields'] = array();
     $sql['where'] = array();
     $sql['additionalWhereClause'] = array();
     $sql['orderings'] = array();
     $sql['limit'] = (int) $query->getLimit() ?: null;
     $sql['offset'] = (int) $query->getOffset() ?: null;
     $sql['tableAliasMap'] = array();
     $source = $query->getSource();
     $this->parseSource($source, $sql);
     $this->parseConstraint($query->getConstraint(), $source, $sql);
     $this->parseOrderings($query->getOrderings(), $source, $sql);
     foreach ($sql['tableAliasMap'] as $tableAlias => $tableName) {
         $additionalWhereClause = $this->getAdditionalWhereClause($query->getQuerySettings(), $tableName, $tableAlias);
         if ($additionalWhereClause !== '') {
             $additionalWhereClause = $this->addNullConditionToStatementIfRequired($sql, $additionalWhereClause, $tableAlias);
             $sql['additionalWhereClause'][] = $additionalWhereClause;
         }
     }
     return $sql;
 }