build() public static method

public static build ( Condition[] $component, array $options = [] ) : string
$component Condition[] The component to be built.
$options array Parameters for building.
return string
Exemplo n.º 1
0
 /**
  * @return string
  */
 public function build()
 {
     $ret = 'DELETE ' . OptionsArray::build($this->options);
     if ($this->columns != NULL && count($this->columns) > 0) {
         $ret .= ' ' . ExpressionArray::build($this->columns);
     }
     if ($this->from != NULL && count($this->from) > 0) {
         $ret .= ' FROM ' . ExpressionArray::build($this->from);
     }
     if ($this->using != NULL && count($this->using) > 0) {
         $ret .= ' USING ' . ExpressionArray::build($this->using);
     }
     if ($this->where != NULL && count($this->where) > 0) {
         $ret .= ' WHERE ' . Condition::build($this->where);
     }
     if ($this->order != NULL && count($this->order) > 0) {
         $ret .= ' ORDER BY ' . ExpressionArray::build($this->order);
     }
     if ($this->limit != NULL && count($this->limit) > 0) {
         $ret .= ' LIMIT ' . Limit::build($this->limit);
     }
     return $ret;
 }
Exemplo n.º 2
0
 /**
  * @param JoinKeyword[] $component The component to be built.
  * @param array         $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     $ret = array();
     foreach ($component as $c) {
         $ret[] = array_search($c->type, static::$JOINS) . ' ' . $c->expr . (!empty($c->on) ? ' ON ' . Condition::build($c->on) : ' USING ' . ArrayObj::build($c->using));
     }
     return implode(' ', $ret);
 }
Exemplo n.º 3
0
 /**
  * @param JoinKeyword[] $component The component to be built.
  * @param array         $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     $ret = array();
     foreach ($component as $c) {
         $ret[] = array_search($c->type, static::$JOINS) . ' ' . $c->expr . ' ON ' . Condition::build($c->on);
     }
     return implode(' ', $ret);
 }
Exemplo n.º 4
0
 /**
  * @param JoinKeyword[] $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     $ret = array();
     foreach ($component as $c) {
         $ret[] = ($c->type === 'JOIN' ? 'JOIN ' : $c->type . ' JOIN ') . Expression::build($c->expr) . ' ON ' . Condition::build($c->on);
     }
     return implode(' ', $ret);
 }
Exemplo n.º 5
0
 /**
  * @param Expression $component The component to be built.
  * @param array      $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     $ret = 'CASE ';
     if (isset($component->value)) {
         // Syntax type 0
         $ret .= $component->value . ' ';
         for ($i = 0; $i < count($component->compare_values) && $i < count($component->results); ++$i) {
             $ret .= 'WHEN ' . $component->compare_values[$i] . ' ';
             $ret .= 'THEN ' . $component->results[$i] . ' ';
         }
     } else {
         // Syntax type 1
         for ($i = 0; $i < count($component->conditions) && $i < count($component->results); ++$i) {
             $ret .= 'WHEN ' . Condition::build($component->conditions[$i]) . ' ';
             $ret .= 'THEN ' . $component->results[$i] . ' ';
         }
     }
     if (isset($component->else_result)) {
         $ret .= 'ELSE ' . $component->else_result . ' ';
     }
     $ret .= 'END';
     return $ret;
 }