当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::createIndex方法代码示例

本文整理汇总了PHP中yii\db\Migration::createIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::createIndex方法的具体用法?PHP Migration::createIndex怎么用?PHP Migration::createIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\Migration的用法示例。


在下文中一共展示了Migration::createIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createIndex

 public function createIndex($name, $table, $columns, $unique = false)
 {
     if (is_null($name)) {
         $name = self::formIndexName($table, $columns, $unique ? "unq" : "idx");
     }
     return parent::createIndex($name, $table, $columns, $unique);
 }
开发者ID:carono,项目名称:yii2-installer,代码行数:7,代码来源:Migration.php

示例2: createIndex

 /**
  * Builds and executes a SQL statement for creating a new index.
  * @param string $name the name of the index. The name will be properly quoted by the method.
  * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method.
  * @param string $column the column(s) that should be included in the index. If there are multiple columns, please separate them
  * by commas or use an array. The column names will be properly quoted by the method.
  * @param boolean $unique whether to add UNIQUE constraint on the created index.
  */
 public function createIndex($name, $table, $column, $unique = false)
 {
     if (in_array($this->db->getDriverName(), array('mysql', 'mysqli')) && $table != strtolower($table)) {
         echo "    > create (via alter table)" . ($unique ? ' unique' : '') . " index {$name} on {$table} (" . implode(',', (array) $column) . ") ...";
         $time = microtime(true);
         $sql = 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD ' . ($unique ? 'UNIQUE INDEX' : 'INDEX') . ' ' . $this->db->quoteTableName($name) . ' (' . $this->db->getQueryBuilder()->buildColumns($column) . ')';
         $this->db->createCommand($sql)->execute();
         echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
     } else {
         parent::createIndex($name, $table, $column, $unique);
     }
 }
开发者ID:fangface,项目名称:yii2-concord,代码行数:20,代码来源:Migration.php

示例3: createIndex

 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function createIndex($name, $table, $columns, $unique = false)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::createIndex($name, $table, $columns, $unique);
 }
开发者ID:flexibuild,项目名称:migrate,代码行数:9,代码来源:Migration.php

示例4: createIndex

 /**
  * @inheritdoc
  * @param string|null $name
  */
 public function createIndex($name, $table, $columns, $unique = false)
 {
     if (is_null($name)) {
         $name = implode('-', (array) $columns);
     }
     parent::createIndex($name, $table, $columns, $unique);
 }
开发者ID:ivan-chkv,项目名称:yii2-boost,代码行数:11,代码来源:Migration.php

示例5: createIndex

 /**
  * Builds and executes a SQL statement for creating a new index.
  * @param string $name the name of the index. The name will be properly quoted by the method.
  * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method.
  * @param string|array $columns the column(s) that should be included in the index. If there are multiple columns, please separate them
  * by commas or use an array. Each column name will be properly quoted by the method. Quoting will be skipped for column names that
  * include a left parenthesis "(".
  * @param boolean $unique whether to add UNIQUE constraint on the created index.
  */
 public function createIndex($table, $columns, $unique = false, $name = null)
 {
     $name = $name ?: $this->getNameIndex($table, $columns);
     parent::createIndex($name, $table, $columns, $unique);
 }
开发者ID:lav45,项目名称:yii2-db-migrate,代码行数:14,代码来源:Migration.php


注:本文中的yii\db\Migration::createIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。