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


PHP db\Migration類代碼示例

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


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

示例1: actionUpdate

 /**
  * Update ip-geo-base data
  *
  * @throws \yii\base\Exception
  */
 public function actionUpdate()
 {
     $migrate = new Migration();
     $migrate->dropForeignKey('fk-geobase_contact-geobase_city_id', 'geobase_contact');
     $ipGeoBase = new IpGeoBase();
     $ipGeoBase->updateDB();
     $migrate->addForeignKey('fk-geobase_contact-geobase_city_id', 'geobase_contact', 'geobase_city_id', 'geobase_city', 'id', 'CASCADE', 'CASCADE');
 }
開發者ID:mark38,項目名稱:yii2-site-mng,代碼行數:13,代碼來源:DefaultController.php

示例2: install

 public function install()
 {
     parent::install();
     $migration = new Migration();
     $migration->createTable($this->getTable(), ['id' => Schema::TYPE_PK, 'object_id' => Schema::TYPE_INTEGER, 'term_id' => Schema::TYPE_BIGINT, 'value' => Schema::TYPE_STRING]);
     if ($migration->db->driverName === 'mysql') {
         $migration->addForeignKey('fk_' . $this->getTable() . '_' . $this->getRefTableName(), $this->getTable(), 'object_id', $this->getRefTableName(), 'id', 'CASCADE');
         $migration->addForeignKey('fk_' . $this->getTable() . '_' . TaxonomyTerms::tableName(), $this->getTable(), 'term_id', TaxonomyTerms::tableName(), 'id', 'CASCADE');
     }
 }
開發者ID:traykovn,項目名稱:yii2-taxonomy,代碼行數:10,代碼來源:PropertyTerm.php

示例3: setUp

 public function setUp()
 {
     $this->migrateControllerClass = MigrateController::className();
     $this->migrationBaseClass = Migration::className();
     $this->mockApplication(['components' => ['db' => ['class' => 'yii\\db\\Connection', 'dsn' => 'sqlite::memory:']]]);
     $this->setUpMigrationPath();
     parent::setUp();
 }
開發者ID:aivavic,項目名稱:yii2,代碼行數:8,代碼來源:MigrateControllerTest.php

示例4: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
 }
開發者ID:singleso,項目名稱:singleso,代碼行數:10,代碼來源:Migration.php

示例5: createTable

 /**
  * @inheritdoc
  */
 public function createTable($table, $columns, $options = null)
 {
     if ($options === null && $this->db->driverName === 'mysql') {
         $options = "CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB";
     }
     parent::createTable($table, $columns, $options);
 }
開發者ID:VeerUP,項目名稱:rest-service,代碼行數:10,代碼來源:Migration.php

示例6: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Yii::$app->db->driverName === 'mysql') {
         $this->tableOptions = 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci';
     }
 }
開發者ID:ssjssh,項目名稱:yii2.0.6-with-annotate,代碼行數:10,代碼來源:Migration.php

示例7: init

 public function init()
 {
     parent::init();
     Yii::setAlias('@webroot', '@frontend/web');
     Yii::setAlias('@web', '/');
     Yii::$app->set('assetManager', $this->assetManager);
 }
開發者ID:lav45,項目名稱:yii2-translated-behavior-demo,代碼行數:7,代碼來源:m160418_201842_page_data.php

示例8: init

 /**
  * Initialize migrations.
  * Calls parent init method, then loads current authManager instance.
  * 
  * @return DbManager
  * @throws yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     $this->authManager = Yii::$app->getAuthManager();
     if (!$this->authManager instanceof DbManager) {
         throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.');
     }
 }
開發者ID:jarrus90,項目名稱:yii2-user,代碼行數:15,代碼來源:RbacMigration.php

示例9: init

 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     } else {
         throw new InvalidConfigException($this->db->driverName . " is not support");
     }
 }
開發者ID:johnitvn,項目名稱:mg075hynlo5793r5gt,代碼行數:9,代碼來源:BaseMigration.php

示例10: createTable

 /**
  * @inheritdoc
  */
 public function createTable($name, $columns, $options = null)
 {
     $baseTableName = $this->db->getSchema()->getRawTableName($name);
     if ($this->db->getSchema()->getTableSchema($baseTableName, true) !== null) {
         echo "    > table {$name} already exists ...\n";
         return;
     }
     parent::createTable($name, $columns, $options);
 }
開發者ID:vipantonio,項目名稱:yii2-firebirddb,代碼行數:12,代碼來源:FirebirdMigration.php

示例11: init

 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         //Mysql 表選項
         $engine = $this->useTransaction ? 'InnoDB' : 'MyISAM';
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=' . $engine;
     }
 }
開發者ID:zwq,項目名稱:yii2_restful,代碼行數:9,代碼來源:Migration.php

示例12: init

 public function init()
 {
     parent::init();
     /** @var Manager $attachment */
     $attachment = Manager::getInstance();
     if (!$attachment instanceof Manager) {
         throw new InvalidConfigException('Attachment Manager component not defined');
     }
     $this->attachmentTable = $attachment->attachmentFileTable;
 }
開發者ID:artkost,項目名稱:yii2-attachment,代碼行數:10,代碼來源:m141207_024254_create_attachment_table.php

示例13: init

 /**
  * {@inheritdoc}
  */
 public function init()
 {
     parent::init();
     switch (Yii::$app->db->driverName) {
         case 'mysql':
             $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
             break;
         default:
             $this->tableOptions = null;
     }
 }
開發者ID:yii2mod,項目名稱:base,代碼行數:14,代碼來源:Migration.php

示例14: init

 /**
  * Initializes the migration.
  * This method will set tableOptions to use InnoDB if the db driver is mysql.
  */
 public function init()
 {
     parent::init();
     if ($this->tableOptions === true) {
         if ($this->db->driverName === 'mysql') {
             $this->tableOptions = 'ENGINE=InnoDB';
         } else {
             $this->tableOptions = '';
         }
     }
 }
開發者ID:nkovacs,項目名稱:yii2-table-builder,代碼行數:15,代碼來源:Migration.php

示例15: init

 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     if (is_null($this->_tableName)) {
         throw new InvalidConfigException('$_tableName must be set!');
     }
     if ($this->db->driverName === 'mysql' && $this->_tableOptions !== false) {
         // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
         $this->_tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     parent::init();
 }
開發者ID:sirroland,項目名稱:yii2-migen,代碼行數:14,代碼來源:Migration.php


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