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


PHP Migration::addPrimaryKey方法代碼示例

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


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

示例1: runCreateTable

 /**
  * Create table in database
  */
 public function runCreateTable()
 {
     $this->dropTable();
     if ($this->hideMigrationOutput) {
         ob_start();
     }
     /** @var Connection $_conn */
     $_conn = Yii::$app->{$this->db};
     if (!$_conn->schema->getTableSchema($this->tableName)) {
         $this->migrationClass->createTable($this->tableNameRaw, $this->columns);
         if (is_array($this->primaryKeys) && sizeof($this->primaryKeys)) {
             try {
                 $this->migrationClass->addPrimaryKey("{$this->tableNameRaw}_pk", $this->tableNameRaw, $this->primaryKeys);
             } catch (\yii\db\Exception $exp) {
             }
         }
     }
     if ($this->hideMigrationOutput) {
         ob_clean();
         ob_flush();
     }
 }
開發者ID:infinitydevphp,項目名稱:yii2-table-builder,代碼行數:25,代碼來源:TableBuilder.php

示例2: addPrimaryKey

 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function addPrimaryKey($name, $table, $columns)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::addPrimaryKey($name, $table, $columns);
 }
開發者ID:flexibuild,項目名稱:migrate,代碼行數:9,代碼來源:Migration.php

示例3: addPrimaryKey

 /**
  * @inheritdoc
  * @param string|null $name
  */
 public function addPrimaryKey($name, $table, $columns)
 {
     if (is_null($name)) {
         $name = implode('-', (array) $columns);
     }
     parent::addPrimaryKey($name, $table, $columns);
 }
開發者ID:ivan-chkv,項目名稱:yii2-boost,代碼行數:11,代碼來源:Migration.php

示例4: addPrimaryKey

 /**
  * Builds and executes a SQL statement for creating a primary key.
  * The method will properly quote the table and column names.
  * @param string $table the table that the primary key constraint will be added to.
  * @param string|array $columns comma separated string or array of columns that the primary key will consist of.
  * @param string $name default null, the name of the primary key constraint.
  */
 public function addPrimaryKey($table, $columns, $name = null)
 {
     $name = $name ?: $this->getNamePrimaryKey($table);
     parent::addPrimaryKey($name, $table, $columns);
 }
開發者ID:lav45,項目名稱:yii2-db-migrate,代碼行數:12,代碼來源:Migration.php

示例5: addPrimaryKey

 public function addPrimaryKey($name, $table, $columns)
 {
     if (is_null($name)) {
         $name = self::formIndexName($table, $columns, 'pk');
     }
     return parent::addPrimaryKey($name, $table, $columns);
 }
開發者ID:carono,項目名稱:yii2-installer,代碼行數:7,代碼來源:Migration.php


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