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


PHP Migration::decimal方法代码示例

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


在下文中一共展示了Migration::decimal方法的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;
 }
开发者ID:infinitydevphp,项目名称:yii2-table-builder,代码行数:97,代码来源:TableBuilder.php


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