示例#1
0
 /**
  * Transforms a constraint into SQL and parameter arrays
  *
  * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint The constraint
  * @param SourceInterface $source The source
  * @param array &$sql The query parts
  * @param array &$parameters The parameters that will replace the markers
  * @return void
  */
 protected function parseConstraint(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint = NULL, SourceInterface $source, array &$sql, array &$parameters)
 {
     if ($constraint instanceof \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface) {
         $sql['where'][] = '(';
         $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters);
         $sql['where'][] = ' AND ';
         $this->parseConstraint($constraint->getConstraint2(), $source, $sql, $parameters);
         $sql['where'][] = ')';
     } elseif ($constraint instanceof \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface) {
         $sql['where'][] = '(';
         $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters);
         $sql['where'][] = ' OR ';
         $this->parseConstraint($constraint->getConstraint2(), $source, $sql, $parameters);
         $sql['where'][] = ')';
     } elseif ($constraint instanceof \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface) {
         $sql['where'][] = 'NOT (';
         $this->parseConstraint($constraint->getConstraint(), $source, $sql, $parameters);
         $sql['where'][] = ')';
     } elseif ($constraint instanceof ComparisonInterface) {
         $this->parseComparison($constraint, $source, $sql, $parameters);
     }
 }
示例#2
0
 /**
  * Transforms a constraint into SQL and parameter arrays
  *
  * @param Qom\ConstraintInterface $constraint The constraint
  * @param Qom\SourceInterface $source The source
  * @param array &$sql The query parts
  * @return void
  */
 protected function parseConstraint(Qom\ConstraintInterface $constraint = NULL, Qom\SourceInterface $source, array &$sql)
 {
     if ($constraint instanceof Qom\AndInterface) {
         $sql['where'][] = '(';
         $this->parseConstraint($constraint->getConstraint1(), $source, $sql);
         $sql['where'][] = ' AND ';
         $this->parseConstraint($constraint->getConstraint2(), $source, $sql);
         $sql['where'][] = ')';
     } elseif ($constraint instanceof Qom\OrInterface) {
         $sql['where'][] = '(';
         $this->parseConstraint($constraint->getConstraint1(), $source, $sql);
         $sql['where'][] = ' OR ';
         $this->parseConstraint($constraint->getConstraint2(), $source, $sql);
         $sql['where'][] = ')';
     } elseif ($constraint instanceof Qom\NotInterface) {
         $sql['where'][] = 'NOT (';
         $this->parseConstraint($constraint->getConstraint(), $source, $sql);
         $sql['where'][] = ')';
     } elseif ($constraint instanceof Qom\ComparisonInterface) {
         $this->parseComparison($constraint, $source, $sql);
     }
 }
示例#3
0
 /**
  * Transforms a constraint into SQL and parameter arrays
  *
  * @param Qom\ConstraintInterface $constraint The constraint
  * @param Qom\SourceInterface $source The source
  * @return CompositeExpression|string
  * @throws \RuntimeException
  */
 protected function parseConstraint(Qom\ConstraintInterface $constraint, Qom\SourceInterface $source)
 {
     if ($constraint instanceof Qom\AndInterface) {
         $constraint1 = $constraint->getConstraint1();
         $constraint2 = $constraint->getConstraint2();
         if ($constraint1 instanceof Qom\ConstraintInterface && $constraint2 instanceof Qom\ConstraintInterface) {
             return $this->queryBuilder->expr()->andX($this->parseConstraint($constraint1, $source), $this->parseConstraint($constraint2, $source));
         } else {
             return '';
         }
     } elseif ($constraint instanceof Qom\OrInterface) {
         $constraint1 = $constraint->getConstraint1();
         $constraint2 = $constraint->getConstraint2();
         if ($constraint1 instanceof Qom\ConstraintInterface && $constraint2 instanceof Qom\ConstraintInterface) {
             return $this->queryBuilder->expr()->orX($this->parseConstraint($constraint->getConstraint1(), $source), $this->parseConstraint($constraint->getConstraint2(), $source));
         } else {
             return '';
         }
     } elseif ($constraint instanceof Qom\NotInterface) {
         return ' NOT(' . $this->parseConstraint($constraint->getConstraint(), $source) . ')';
     } elseif ($constraint instanceof Qom\ComparisonInterface) {
         return $this->parseComparison($constraint, $source);
     } else {
         throw new \RuntimeException('not implemented', 1476199898);
     }
 }