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


PHP Context::escape方法代碼示例

本文整理匯總了PHP中SqlParser\Context::escape方法的典型用法代碼示例。如果您正苦於以下問題:PHP Context::escape方法的具體用法?PHP Context::escape怎麽用?PHP Context::escape使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SqlParser\Context的用法示例。


在下文中一共展示了Context::escape方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testEscape

 public function testEscape()
 {
     Context::setMode('ANSI_QUOTES');
     $this->assertEquals('"test"', Context::escape('test'));
     Context::setMode();
     $this->assertEquals('`test`', Context::escape('test'));
     $this->assertEquals(array('`a`', '`b`'), Context::escape(array('a', 'b')));
 }
開發者ID:elrossco22,項目名稱:sql-parser,代碼行數:8,代碼來源:ContextTest.php

示例2: build

 /**
  * @param Expression|Expression[] $component The component to be built.
  * @param array                   $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     if (is_array($component)) {
         return implode($component, ', ');
     } else {
         if ($component->expr !== '' && !is_null($component->expr)) {
             $ret = $component->expr;
         } else {
             $fields = array();
             if (isset($component->database) && $component->database !== '') {
                 $fields[] = $component->database;
             }
             if (isset($component->table) && $component->table !== '') {
                 $fields[] = $component->table;
             }
             if (isset($component->column) && $component->column !== '') {
                 $fields[] = $component->column;
             }
             $ret = implode('.', Context::escape($fields));
         }
         if (!empty($component->alias)) {
             $ret .= ' AS ' . Context::escape($component->alias);
         }
         return $ret;
     }
 }
開發者ID:wp-cloud,項目名稱:phpmyadmin,代碼行數:32,代碼來源:Expression.php

示例3: build

 /**
  * @param Reference $component The component to be built.
  * @param array     $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     return trim(Context::escape($component->table) . ' (' . implode(', ', Context::escape($component->columns)) . ') ' . $component->options);
 }
開發者ID:altesien,項目名稱:FinalProject,代碼行數:10,代碼來源:Reference.php

示例4: build

 /**
  * @param CreateDefinition|CreateDefinition[] $component The component to be built.
  * @param array                               $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     if (is_array($component)) {
         return "(\n  " . implode(",\n  ", $component) . "\n)";
     } else {
         $tmp = '';
         if ($component->isConstraint) {
             $tmp .= 'CONSTRAINT ';
         }
         if (isset($component->name) && $component->name !== '') {
             $tmp .= Context::escape($component->name) . ' ';
         }
         if (!empty($component->type)) {
             $tmp .= DataType::build($component->type, array('lowercase' => true)) . ' ';
         }
         if (!empty($component->key)) {
             $tmp .= $component->key . ' ';
         }
         if (!empty($component->references)) {
             $tmp .= 'REFERENCES ' . $component->references . ' ';
         }
         $tmp .= $component->options;
         return trim($tmp);
     }
 }
開發者ID:altesien,項目名稱:FinalProject,代碼行數:31,代碼來源:CreateDefinition.php

示例5: build

 /**
  * @param Key   $component The component to be built.
  * @param array $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     $ret = $component->type . ' ';
     if (!empty($component->name)) {
         $ret .= Context::escape($component->name) . ' ';
     }
     $columns = array();
     foreach ($component->columns as $column) {
         $tmp = Context::escape($column['name']);
         if (isset($column['length'])) {
             $tmp .= '(' . $column['length'] . ')';
         }
         $columns[] = $tmp;
     }
     $ret .= '(' . implode(',', $columns) . ') ' . $component->options;
     return trim($ret);
 }
開發者ID:TheBlackBloodyUnicorn,項目名稱:pico_wanderblog,代碼行數:23,代碼來源:Key.php

示例6: build

 /**
  * @param Expression $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     if (!empty($component->expr)) {
         $ret = $component->expr;
     } else {
         $fields = array();
         if (!empty($component->database)) {
             $fields[] = $component->database;
         }
         if (!empty($component->table)) {
             $fields[] = $component->table;
         }
         if (!empty($component->column)) {
             $fields[] = $component->column;
         }
         $ret = implode('.', Context::escape($fields));
     }
     if (!empty($component->alias)) {
         $ret .= ' AS ' . Context::escape($component->alias);
     }
     return $ret;
 }
開發者ID:WSDC-NITWarangal,項目名稱:phpmyadmin,代碼行數:27,代碼來源:Expression.php

示例7: build

 /**
  * @param FieldDefinition|FieldDefinition[] $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 {
         $tmp = '';
         if ($component->isConstraint) {
             $tmp .= 'CONSTRAINT ';
         }
         if (!empty($component->name)) {
             $tmp .= Context::escape($component->name) . ' ';
         }
         if (!empty($component->type)) {
             $tmp .= DataType::build($component->type) . ' ';
         }
         if (!empty($component->key)) {
             $tmp .= Key::build($component->key) . ' ';
         }
         if (!empty($component->references)) {
             $tmp .= 'REFERENCES ' . Reference::build($component->references) . ' ';
         }
         $tmp .= OptionsArray::build($component->options);
         return trim($tmp);
     }
 }
開發者ID:saisai,項目名稱:phpmyadmin,代碼行數:34,代碼來源:FieldDefinition.php

示例8: build

 /**
  * @param ParameterDefinition[] $component The component to be built.
  * @param array                 $options   Parameters for building.
  *
  * @return string
  */
 public static function build($component, array $options = array())
 {
     if (is_array($component)) {
         return '(' . implode(', ', $component) . ')';
     } else {
         $tmp = '';
         if (!empty($component->inOut)) {
             $tmp .= $component->inOut . ' ';
         }
         return trim($tmp . Context::escape($component->name) . ' ' . $component->type);
     }
 }
開發者ID:itgsod-philip-skalander,項目名稱:phpmyadmin,代碼行數:18,代碼來源:ParameterDefinition.php

示例9: build

 /**
  * @param Key $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     $ret = $component->type . ' ';
     if (!empty($component->name)) {
         $ret .= Context::escape($component->name) . ' ';
     }
     $ret .= '(' . implode(',', Context::escape($component->columns)) . ')';
     $ret .= OptionsArray::build($component->options);
     return trim($ret);
 }
開發者ID:WSDC-NITWarangal,項目名稱:phpmyadmin,代碼行數:15,代碼來源:Key.php

示例10: replaceWithAliases


//.........這裏部分代碼省略.........
         $old_table = $statement->name->table;
         // Finding the aliased database name.
         // The database might be empty so we have to add a few checks.
         $new_database = null;
         if (!empty($statement->name->database)) {
             $new_database = $statement->name->database;
             if (!empty($aliases[$old_database]['alias'])) {
                 $new_database = $aliases[$old_database]['alias'];
             }
         }
         // Finding the aliases table name.
         $new_table = $old_table;
         if (!empty($aliases[$old_database]['tables'][$old_table]['alias'])) {
             $new_table = $aliases[$old_database]['tables'][$old_table]['alias'];
         }
         // Replacing new values.
         if ($statement->name->database !== $new_database || $statement->name->table !== $new_table) {
             $statement->name->database = $new_database;
             $statement->name->table = $new_table;
             $statement->name->expr = null;
             // Force rebuild.
             $flag = true;
         }
         foreach ($statement->fields as $field) {
             // Column name.
             if (!empty($field->type)) {
                 if (!empty($aliases[$old_database]['tables'][$old_table]['columns'][$field->name])) {
                     $field->name = $aliases[$old_database]['tables'][$old_table]['columns'][$field->name];
                     $flag = true;
                 }
             }
             // Key's columns.
             if (!empty($field->key)) {
                 foreach ($field->key->columns as $key => $column) {
                     if (!empty($aliases[$old_database]['tables'][$old_table]['columns'][$column['name']])) {
                         $field->key->columns[$key]['name'] = $aliases[$old_database]['tables'][$old_table]['columns'][$column['name']];
                         $flag = true;
                     }
                 }
             }
             // References.
             if (!empty($field->references)) {
                 $ref_table = $field->references->table->table;
                 // Replacing table.
                 if (!empty($aliases[$old_database]['tables'][$ref_table]['alias'])) {
                     $field->references->table->table = $aliases[$old_database]['tables'][$ref_table]['alias'];
                     $field->references->table->expr = null;
                     $flag = true;
                 }
                 // Replacing column names.
                 foreach ($field->references->columns as $key => $column) {
                     if (!empty($aliases[$old_database]['tables'][$ref_table]['columns'][$column])) {
                         $field->references->columns[$key] = $aliases[$old_database]['tables'][$ref_table]['columns'][$column];
                         $flag = true;
                     }
                 }
             }
         }
     } elseif ($statement->options->has('TRIGGER')) {
         // Extracting the name of the old database and table from the
         // statement to make sure the parameters are corect.
         if (!empty($statement->table->database)) {
             $old_database = $statement->table->database;
         }
         /**
          * Old table name.
          *
          * @var string $old_table
          */
         $old_table = $statement->table->table;
         if (!empty($aliases[$old_database]['tables'][$old_table]['alias'])) {
             $statement->table->table = $aliases[$old_database]['tables'][$old_table]['alias'];
             $statement->table->expr = null;
             // Force rebuild.
             $flag = true;
         }
     }
     if ($statement->options->has('TRIGGER') || $statement->options->has('PROCEDURE') || $statement->options->has('FUNCTION') || $statement->options->has('VIEW')) {
         // Repalcing the body.
         for ($i = 0, $count = count($statement->body); $i < $count; ++$i) {
             /**
              * Token parsed at this moment.
              *
              * @var Token $token
              */
             $token = $statement->body[$i];
             // Replacing only symbols (that are not variables) and unknown
             // identifiers.
             if ($token->type === Token::TYPE_SYMBOL && !($token->flags & Token::FLAG_SYMBOL_VARIABLE) || ($token->type === Token::TYPE_KEYWORD && !($token->flags & Token::FLAG_KEYWORD_RESERVED) || $token->type === Token::TYPE_NONE)) {
                 $alias = $this->getAlias($aliases, $token->value);
                 if (!empty($alias)) {
                     // Replacing the token.
                     $token->token = Context::escape($alias);
                     $flag = true;
                 }
             }
         }
     }
     return $statement->build();
 }
開發者ID:ryanfmurphy,項目名稱:phpmyadmin,代碼行數:101,代碼來源:ExportSql.php

示例11: build

 /**
  * @param ParameterDefinition[] $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     $ret = array();
     foreach ($component as $c) {
         $tmp = '';
         if (!empty($c->inOut)) {
             $tmp .= $c->inOut . ' ';
         }
         $ret[] = trim($tmp . Context::escape($c->name) . ' ' . DataType::build($c->type));
     }
     return '(' . implode(', ', $ret) . ')';
 }
開發者ID:WSDC-NITWarangal,項目名稱:phpmyadmin,代碼行數:17,代碼來源:ParameterDefinition.php

示例12: build

 /**
  * @param Reference $component The component to be built.
  *
  * @return string
  */
 public static function build($component)
 {
     return trim(Context::escape($component->table) . ' (' . implode(', ', Context::escape($component->columns)) . ') ' . OptionsArray::build($component->options));
 }
開發者ID:WSDC-NITWarangal,項目名稱:phpmyadmin,代碼行數:9,代碼來源:Reference.php


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