當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Expression::build方法代碼示例

本文整理匯總了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;
     }
 }
開發者ID:nobodypb,項目名稱:phpmyadmin,代碼行數:17,代碼來源:OrderKeyword.php

示例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;
 }
開發者ID:itgsod-philip-skalander,項目名稱:phpmyadmin,代碼行數:41,代碼來源:Query.php

示例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`');
 }
開發者ID:elrossco22,項目名稱:sql-parser,代碼行數:5,代碼來源:ExpressionTest.php

示例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 '';
 }
開發者ID:FuhrerMalkovich,項目名稱:Blogpost,代碼行數:48,代碼來源:CreateStatement.php

示例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;
 }
開發者ID:rushi963,項目名稱:phpmyadmin,代碼行數:14,代碼來源:AlterOperation.php

示例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);
 }
開發者ID:urstrulymahesh,項目名稱:phpmyadmin,代碼行數:11,代碼來源:AlterStatement.php

示例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);
 }
開發者ID:nobodypb,項目名稱:phpmyadmin,代碼行數:13,代碼來源:JoinKeyword.php

示例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 . '"';
     }
 }
開發者ID:WSDC-NITWarangal,項目名稱:phpmyadmin,代碼行數:14,代碼來源:IntoKeyword.php

示例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);
     }
 }
開發者ID:WSDC-NITWarangal,項目名稱:phpmyadmin,代碼行數:17,代碼來源:RenameOperation.php


注:本文中的SqlParser\Components\Expression::build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。