build() public static method

public static build ( ArrayObj | ArrayObj[] $component, array $options = [] ) : string
$component ArrayObj | ArrayObj[] The component to be built.
$options array Parameters for building.
return string
Exemplo n.º 1
0
 /**
  * @param FunctionCall $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     return $component->name . ArrayObj::build($component->parameters);
 }
Exemplo n.º 2
0
 /**
  * @return string
  */
 public function build()
 {
     $fields = '';
     if (!empty($this->fields)) {
         if (is_array($this->fields)) {
             $fields = CreateDefinition::build($this->fields) . ' ';
         } elseif ($this->fields instanceof ArrayObj) {
             $fields = ArrayObj::build($this->fields);
         }
     }
     if ($this->options->has('DATABASE')) {
         return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . OptionsArray::build($this->entityOptions);
     } elseif ($this->options->has('TABLE')) {
         $partition = '';
         if (!empty($this->partitionBy)) {
             $partition .= "\nPARTITION BY " . $this->partitionBy;
         }
         if (!empty($this->partitionsNum)) {
             $partition .= "\nPARTITIONS " . $this->partitionsNum;
         }
         if (!empty($this->subpartitionBy)) {
             $partition .= "\nSUBPARTITION BY " . $this->subpartitionBy;
         }
         if (!empty($this->subpartitionsNum)) {
             $partition .= "\nSUBPARTITIONS " . $this->subpartitionsNum;
         }
         if (!empty($this->partitions)) {
             $partition .= "\n" . PartitionDefinition::build($this->partitions);
         }
         return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . $fields . OptionsArray::build($this->entityOptions) . $partition;
     } elseif ($this->options->has('VIEW')) {
         return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . $fields . ' AS ' . TokensList::build($this->body) . ' ' . OptionsArray::build($this->entityOptions);
     } elseif ($this->options->has('TRIGGER')) {
         return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . OptionsArray::build($this->entityOptions) . ' ' . 'ON ' . Expression::build($this->table) . ' ' . 'FOR EACH ROW ' . TokensList::build($this->body);
     } elseif ($this->options->has('PROCEDURE') || $this->options->has('FUNCTION')) {
         $tmp = '';
         if ($this->options->has('FUNCTION')) {
             $tmp = 'RETURNS ' . DataType::build($this->return);
         }
         return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . ParameterDefinition::build($this->parameters) . ' ' . $tmp . ' ' . TokensList::build($this->body);
     } else {
         return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . TokensList::build($this->body);
     }
     return '';
 }
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 . (!empty($c->on) ? ' ON ' . Condition::build($c->on) : ' USING ' . ArrayObj::build($c->using));
     }
     return implode(' ', $ret);
 }
 /**
  * @param ArrayObj[] $component The component to be built.
  * @param array      $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     return ArrayObj::build($component);
 }
Exemplo n.º 5
0
 /**
  * @return string
  */
 public function build()
 {
     return 'INSERT ' . $this->options . ' INTO ' . $this->into . ' VALUES ' . ArrayObj::build($this->values);
 }
Exemplo n.º 6
0
 /**
  * @param ArrayObj[] $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     return ArrayObj::build($component);
 }
Exemplo n.º 7
0
 public function testBuildValues()
 {
     $component = new ArrayObj(array(), array('a', 'b'));
     $this->assertEquals('(a, b)', ArrayObj::build($component));
 }