Beispiel #1
0
 public function or_($condition)
 {
     if (!$condition instanceof Condition) {
         $condition = new Condition($condition);
     }
     $condition->connector(Condition::OR_);
     $this->add($condition);
 }
Beispiel #2
0
 public function build(Breakdown $bk, $tabs)
 {
     if ($this->function != null) {
         $this->function->build($bk, $tabs);
     }
     if ($this->column !== null) {
         $bk->append(" " . $this->column);
     }
     if (count($this->values) > 1) {
         $bk->append(" (");
     }
     $doCommaValues = false;
     foreach ($this->values as $val) {
         /** @var Values $val */
         if ($doCommaValues) {
             $bk->append(",");
         } else {
             $doCommaValues = true;
         }
         $val->build($bk, $tabs);
     }
     if (count($this->values) > 1) {
         $bk->append(" )");
     }
     if ($this->fieldSql != null) {
         if ($this->fieldSql->hasType()) {
             //Don't put parenthesis when it is not a complex query like SELECT,INSERT.
             $bk->append(" (");
             //Non complex queries are just VALUES.. FUNCTIONS
         }
         $this->fieldSql->build($bk, $tabs);
         if ($this->fieldSql->hasType()) {
             $bk->append(" )");
         }
     }
     if ($this->condition != null) {
         $this->condition->build($bk, $tabs);
     }
     if ($this->case != null) {
         $this->case->build($bk, $tabs);
     }
     $bk->appendAs($this->as_());
 }
Beispiel #3
0
 private function inHelper($args, $conditionType)
 {
     $condition = $this->getLastCall();
     if (count($args) > 1 || !$args[0] instanceof SQL) {
         if (is_array($args[0])) {
             $args = $args[0];
         }
         foreach ($args as $i => $arg) {
             $args[$i] = new Clause\Values($arg);
         }
     }
     if ($condition instanceof Clause\Condition) {
         $condition->equality($conditionType);
         $condition->right(self::instanceHelper('Clause\\Field', $args));
         return $this->called($condition);
     } else {
         $condition = new Clause\Condition();
         $condition->equality($conditionType);
         $condition->right(self::instanceHelper('Clause\\Field', $args));
         $field = new Clause\Field($condition);
         $this->fields[] = $field;
         return $this->called($field);
     }
 }