Ejemplo n.º 1
0
 /**
  * Make string with conditions for LogicOperatorNode
  *
  * @param AbstractLogicOperatorNode $node
  * @return string
  */
 public function makeLogicOperator(AbstractLogicOperatorNode $node)
 {
     $nodeName = $node->getNodeName();
     if (!isset($this->literals['LogicOperator'][$nodeName])) {
         throw new DataStoresException('The Logic Operator not suppoted: ' . $nodeName);
     }
     $arrayQueries = $node->getQueries();
     $strQuery = $this->literals['LogicOperator'][$nodeName]['before'];
     foreach ($arrayQueries as $queryNode) {
         /* @var $queryNode AbstractQueryNode */
         $strQuery = $strQuery . $this->makeAbstractQueryOperator($queryNode) . $this->literals['LogicOperator'][$nodeName]['between'];
     }
     $strQuery = rtrim($strQuery, $this->literals['LogicOperator'][$nodeName]['between']);
     $strQuery = $strQuery . $this->literals['LogicOperator'][$nodeName]['after'];
     return $strQuery;
 }
Ejemplo n.º 2
0
 /**
  * add query (like and or or) to the querybuilder
  *
  * @param string|boolean            $addMethod name of method we will be calling or false if no method is needed
  * @param AbstractLogicOperatorNode $node      AST representation of query operator
  * @param bool                      $expr      should i wrap this in expr()
  *
  * @return Builder|Expr
  */
 protected function visitLogic($addMethod, AbstractLogicOperatorNode $node, $expr = false)
 {
     $builder = $this->builder;
     if ($expr) {
         $builder = $this->builder->expr();
     }
     foreach ($node->getQueries() as $query) {
         $expr = $this->recurse($query, $addMethod !== false);
         if ($addMethod !== false) {
             $builder->{$addMethod}($expr);
         }
     }
     return $builder;
 }