SqlParser\Components\PartitionDefinition::build PHP Method

build() public static method

public static build ( PartitionDefinition | PartitionDefinition[] $component, array $options = [] ) : string
$component PartitionDefinition | PartitionDefinition[] The component to be built.
$options array Parameters for building.
return string
    public static function build($component, array $options = array())
    {
        if (is_array($component)) {
            return "(\n" . implode(",\n", $component) . "\n)";
        } else {
            if ($component->isSubpartition) {
                return trim('SUBPARTITION ' . $component->name . ' ' . $component->options);
            } else {
                $subpartitions = empty($component->subpartitions) ? '' : ' ' . PartitionDefinition::build($component->subpartitions);
                return trim('PARTITION ' . $component->name . (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ') . $component->options . $subpartitions);
            }
        }
    }

Usage Example

 /**
  * @param PartitionDefinition|PartitionDefinition[] $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     if (is_array($component)) {
         $ret = array();
         foreach ($component as $c) {
             $ret[] = static::build($c);
         }
         return "(\n" . implode(",\n", $ret) . "\n)";
     } else {
         if ($component->isSubpartition) {
             return 'SUBPARTITION ' . $component->name;
         } else {
             $subpartitions = empty($component->subpartitions) ? '' : ' ' . PartitionDefinition::build($component->subpartitions);
             return 'PARTITION ' . $component->name . ' VALUES ' . $component->type . ' ' . $component->expr . $subpartitions;
         }
     }
 }
All Usage Examples Of SqlParser\Components\PartitionDefinition::build
PartitionDefinition