本文整理汇总了PHP中SqlParser\Components\Expression::build方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::build方法的具体用法?PHP Expression::build怎么用?PHP Expression::build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlParser\Components\Expression
的用法示例。
在下文中一共展示了Expression::build方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* @param OrderKeyword $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 implode(", ", $ret);
} else {
return Expression::build($component->field) . ' ' . $component->type;
}
}
示例2: getTables
/**
* Gets a list of all tables used in this statement.
*
* @param Statement $statement Statement to be scanned.
*
* @return array
*/
public static function getTables($statement)
{
$expressions = array();
if ($statement instanceof InsertStatement || $statement instanceof ReplaceStatement) {
$expressions = array($statement->into->dest);
} elseif ($statement instanceof UpdateStatement) {
$expressions = $statement->tables;
} elseif ($statement instanceof SelectStatement || $statement instanceof DeleteStatement) {
$expressions = $statement->from;
} elseif ($statement instanceof AlterStatement || $statement instanceof TruncateStatement) {
$expressions = array($statement->table);
} elseif ($statement instanceof DropStatement) {
if (!$statement->options->has('TABLE')) {
// No tables are dropped.
return array();
}
$expressions = $statement->fields;
} elseif ($statement instanceof RenameStatement) {
foreach ($statement->renames as $rename) {
$expressions[] = $rename->old;
}
}
$ret = array();
foreach ($expressions as $expr) {
if (!empty($expr->table)) {
$expr->expr = null;
// Force rebuild.
$expr->alias = null;
// Aliases are not required.
$ret[] = Expression::build($expr);
}
}
return $ret;
}
示例3: testBuild
public function testBuild()
{
$component = array(new Expression('1 + 2', 'three'), new Expression('1 + 3', 'four'));
$this->assertEquals(Expression::build($component), '1 + 2 AS `three`, 1 + 3 AS `four`');
}
示例4: build
/**
* @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 '';
}
示例5: build
/**
* @param AlterOperation $component The component to be built.
*
* @return string
*/
public static function build($component)
{
$ret = OptionsArray::build($component->options) . ' ';
if (!empty($component->field)) {
$ret .= Expression::build($component->field) . ' ';
}
$ret .= TokensList::build($component->unknown);
return $ret;
}
示例6: build
/**
* @return string
*/
public function build()
{
$tmp = array();
foreach ($this->altered as $altered) {
$tmp[] = $altered::build($altered);
}
return 'ALTER ' . OptionsArray::build($this->options) . ' TABLE ' . Expression::build($this->table) . ' ' . implode(', ', $tmp);
}
示例7: build
/**
* @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);
}
示例8: build
/**
* @param IntoKeyword $component The component to be built.
*
* @return string
*/
public static function build($component)
{
if ($component->dest instanceof Expression) {
$columns = !empty($component->columns) ? '(' . implode(', ', $component->columns) . ')' : '';
return Expression::build($component->dest) . $columns;
} else {
return 'OUTFILE "' . $component->dest . '"';
}
}
示例9: build
/**
* @param RenameOperation $component The component to be built.
*
* @return string
*/
public static function build($component)
{
if (is_array($component)) {
$values = array();
foreach ($component as $c) {
$values[] = static::build($c);
}
return implode(', ', $values);
} else {
return Expression::build($component->old) . ' TO ' . Expression::build($component->new);
}
}