本文整理汇总了PHP中yii\db\Migration::smallInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::smallInteger方法的具体用法?PHP Migration::smallInteger怎么用?PHP Migration::smallInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\Migration
的用法示例。
在下文中一共展示了Migration::smallInteger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildNextField
/**
* Create next row migration as ColumnSchemaBuilder
* @param array $config
* @return ColumnSchemaBuilder
*/
protected function buildNextField($config)
{
/** @var ColumnSchemaBuilder $row */
$row = null;
$length = isset($config['length']) && $config['length'] ? $config['length'] : null;
$precision = isset($config['precision']) && $config['length'] ? $config['precision'] : null;
$scale = isset($config['scale']) && $config['length'] ? $config['scale'] : null;
$this->migrationClass = new Migration(['db' => $this->db]);
if (!(isset($config['type']) && $config['type'])) {
throw new \ErrorException("Type field is undefined");
}
switch ($config['type']) {
case Schema::TYPE_PK:
$row = $this->migrationClass->integer($length);
break;
case Schema::TYPE_UPK:
$row = $this->migrationClass->integer($length);
break;
case Schema::TYPE_INTEGER:
$row = $this->migrationClass->integer($length);
break;
case Schema::TYPE_BIGINT:
$row = $this->migrationClass->bigInteger($length);
break;
case Schema::TYPE_BIGPK:
$row = $this->migrationClass->bigInteger($length);
break;
case Schema::TYPE_UBIGPK:
$row = $this->migrationClass->bigInteger($length);
break;
case Schema::TYPE_BINARY:
$row = $this->migrationClass->binary($length);
break;
case Schema::TYPE_CHAR:
$row = $this->migrationClass->char($length);
break;
case Schema::TYPE_TEXT:
$row = $this->migrationClass->text();
break;
case Schema::TYPE_DATE:
$row = $this->{$this}->migrationClass->date();
break;
case Schema::TYPE_DECIMAL:
$row = $this->migrationClass->decimal($precision, $scale);
break;
case Schema::TYPE_DOUBLE:
$row = $this->migrationClass->double($precision);
break;
case Schema::TYPE_FLOAT:
$row = $this->migrationClass->float($precision);
break;
case Schema::TYPE_DATETIME:
$row = $this->migrationClass->dateTime($precision);
break;
case Schema::TYPE_MONEY:
$row = $this->migrationClass->money($precision, $scale);
break;
case Schema::TYPE_SMALLINT:
$row = $this->migrationClass->smallInteger($length);
break;
case Schema::TYPE_TIME:
$row = $this->migrationClass->time($precision);
break;
case Schema::TYPE_TIMESTAMP:
$row = $this->migrationClass->timestamp($precision);
break;
default:
$row = $this->migrationClass->string($length);
break;
}
if (isset($config['type']) && ($config['type'] == Schema::TYPE_UPK || $config['type'] == Schema::TYPE_UBIGPK) || isset($config['unsigned']) && $config['unsigned']) {
$row = $row->unsigned();
}
if (isset($config['default']) && !empty($config['default'])) {
$row = $row->defaultValue($config['default']);
}
if (isset($config['is_not_null']) && $config['is_not_null']) {
$row = $row->notNull();
}
if (isset($config['comment']) && $config['comment']) {
$row = $row->comment($config['comment']);
}
if (isset($config['isCompositeKey']) && $config['isCompositeKey']) {
$this->primaryKeys[] = $config['name'];
}
$config['related_table'] = isset($config['related_table']) ? trim($config['related_table']) : null;
$config['related_field'] = isset($config['related_field']) ? trim($config['related_field']) : null;
if ($config['related_table'] && $config['related_field']) {
$this->relations[] = ['fk_name' => isset($config['fk_name']) && $config['fk_name'] ? $config['fk_name'] : self::getNameForeignKey($this->tableNameRaw, $config['related_table'], $config['name'], $config['related_field'], 255), 'table_name' => $this->addTablePrefix($this->tableNameRaw), 'field' => $config['name'], 'related_table' => $this->addTablePrefix($config['related_table']), 'related_field' => $config['related_field']];
}
return $row;
}