本文整理汇总了PHP中yii\db\Migration::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::init方法的具体用法?PHP Migration::init怎么用?PHP Migration::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\Migration
的用法示例。
在下文中一共展示了Migration::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (Yii::$app->db->driverName === 'mysql') {
$this->tableOptions = 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci';
}
}
示例2: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->db->driverName === 'mysql') {
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
}
示例3: init
public function init()
{
parent::init();
Yii::setAlias('@webroot', '@frontend/web');
Yii::setAlias('@web', '/');
Yii::$app->set('assetManager', $this->assetManager);
}
示例4: 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.');
}
}
示例5: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$db = $this->getDb();
if (in_array($db->getDriverName(), ['mysql', 'mysqli'])) {
$queryBuilder = $db->getQueryBuilder();
$queryBuilder->typeMap = array_merge($queryBuilder->typeMap, [Schema::TYPE_UPK => str_replace('(11)', '(10)', $queryBuilder->typeMap[Schema::TYPE_UPK]), 'tinyint' => 'tinyint(4)', 'utinyint' => 'tinyint(3)', 'usmallint' => 'smallint(5)', 'uinteger' => 'int(10)']);
}
}
示例6: 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;
}
}
示例7: 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");
}
}
示例8: 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;
}
示例9: 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;
}
}
示例10: 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 = '';
}
}
}
示例11: init
/**
* @inheritdoc
*
* @throws NotSupportedException
*/
public function init()
{
parent::init();
if ($this->db->driverName === 'mysql') {
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
} else {
if ((bool) $this->onlyMySql) {
throw new NotSupportedException('MySQL required.');
}
}
}
示例12: 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();
}
示例13: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
switch (Yii::$app->db->driverName) {
case 'mysql':
case 'pgsql':
$this->tableOptions = null;
break;
default:
throw new \RuntimeException('Your database is not supported!');
}
}
示例14: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
switch (\Yii::$app->db->driverName) {
case 'mysql':
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
break;
case 'pgsql':
$this->tableOptions = null;
break;
default:
throw new \RuntimeException('Your database is not supported!');
}
}
示例15: init
public function init()
{
parent::init();
if ($this->file === null) {
$reflection = new \ReflectionClass($this);
$this->file = str_replace('.php', '.sql', $reflection->getFileName());
} else {
$reflection = new \ReflectionClass($this);
$this->file = dirname($reflection->getFileName()) . DIRECTORY_SEPARATOR . $this->file;
}
if (!is_file($this->file)) {
throw new Exception("File {$this->file} not found");
}
}