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


PHP Table::addColumn方法代码示例

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


在下文中一共展示了Table::addColumn方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addColumn

 /**
  * You can pass `autoIncrement` as an option and it will be converted
  * to the correct option for phinx to create the column with an
  * auto increment attribute
  *
  * {@inheritdoc}
  */
 public function addColumn($columnName, $type = null, $options = [])
 {
     if (isset($options['autoIncrement']) && $options['autoIncrement'] === true) {
         $options['identity'] = true;
         unset($options['autoIncrement']);
     }
     return parent::addColumn($columnName, $type, $options);
 }
开发者ID:coretyson,项目名称:coretyson,代码行数:15,代码来源:Table.php

示例2: createSchemaTable

 /**
  * {@inheritdoc}
  */
 public function createSchemaTable()
 {
     try {
         $options = array('id' => false);
         $table = new \Phinx\Db\Table($this->getSchemaTableName(), $options, $this);
         $table->addColumn('version', 'biginteger', array('limit' => 14))->addColumn('start_time', 'timestamp')->addColumn('end_time', 'timestamp')->save();
     } catch (\Exception $exception) {
         throw new \InvalidArgumentException('There was a problem creating the schema table');
     }
 }
开发者ID:pbombo,项目名称:phinx,代码行数:13,代码来源:PdoAdapter.php

示例3: createSchemaTable

 /**
  * {@inheritdoc}
  */
 public function createSchemaTable()
 {
     try {
         $options = array('id' => false, 'primary_key' => 'version');
         $table = new Table($this->getSchemaTableName(), $options, $this);
         if ($this->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql' && version_compare($this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION), '5.6.0', '>=')) {
             $table->addColumn('version', 'biginteger', array('limit' => 14))->addColumn('start_time', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))->addColumn('end_time', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))->save();
         } else {
             $table->addColumn('version', 'biginteger')->addColumn('start_time', 'timestamp')->addColumn('end_time', 'timestamp')->save();
         }
     } catch (\Exception $exception) {
         throw new \InvalidArgumentException('There was a problem creating the schema table: ' . $exception->getMessage());
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:17,代码来源:PdoAdapter.php

示例4: testAddTableWithForeignKey

 public function testAddTableWithForeignKey()
 {
     $this->mock->expects($this->any())->method('isValidColumnType')->with($this->callback(function ($column) {
         return in_array($column->getType(), array('string', 'integer'));
     }))->will($this->returnValue(true));
     $table = new Table('table', array(), $this->adapter);
     $table->addColumn('bar', 'string')->addColumn('relation', 'integer')->addForeignKey('relation', 'target_table', array('id'));
     $this->mock->expects($this->once())->method('createTable')->with($this->callback(function ($table) {
         if ($table->getName() !== 'pre_table_suf') {
             throw new \Exception(sprintf('Table::getName was not prefixed/suffixed properly: "%s"', $table->getName()));
         }
         $fks = $table->getForeignKeys();
         if (count($fks) !== 1) {
             throw new \Exception(sprintf('Table::getForeignKeys count was incorrect: %d', count($fks)));
         }
         foreach ($fks as $fk) {
             if ($fk->getReferencedTable()->getName() !== 'pre_target_table_suf') {
                 throw new \Exception(sprintf('ForeignKey::getReferencedTable was not prefixed/suffixed properly: "%s"', $fk->getReferencedTable->getName()));
             }
         }
         return true;
     }));
     $table->create();
 }
开发者ID:stephenorr,项目名称:phinx,代码行数:24,代码来源:TablePrefixAdapterTest.php

示例5: addColumn

 /**
  * Add a table column.
  *
  * Type can be: string, text, integer, float, decimal, datetime, timestamp,
  * time, date, binary, boolean.
  *
  * Valid options can be: limit, default, null, precision or scale.
  *
  * @param string $columnName
  * @param null   $type
  * @param array  $options
  *
  * @return $this
  */
 public function addColumn($columnName, $type = null, $options = [])
 {
     $this->table->addColumn($columnName, $type, $options);
     return $this;
 }
开发者ID:nilopc-interesting-libs,项目名称:sql-schema-builder,代码行数:19,代码来源:Table.php


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