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


PHP Table::addColumn方法代码示例

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


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

示例1: rebuildSchema

 /**
  * Drops the tables and rebuilds them
  */
 public function rebuildSchema()
 {
     $schemaManager = $this->conn->getSchemaManager();
     $productTable = new Table('product');
     $productTable->addColumn("id", "integer", array("unsigned" => true));
     $productTable->addColumn("name", "string", array("length" => 255));
     $productTable->addColumn('author_id', 'integer', array('notNull' => false));
     $productTable->addColumn("description", "text", array('notNull' => false));
     $productTable->addColumn("price", "decimal", array('scale' => 2, 'notNull' => false));
     $productTable->addColumn("is_published", "boolean");
     $productTable->addColumn('created_at', 'datetime');
     $productTable->setPrimaryKey(array("id"));
     $schemaManager->dropAndCreateTable($productTable);
     $userTable = new Table('user');
     $userTable->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
     $userTable->setPrimaryKey(array('id'));
     $userTable->addColumn('username', 'string', array('length' => 32));
     $userTable->addUniqueIndex(array('username'));
     $userTable->addColumn('password', 'string', array('length' => 255));
     $userTable->addColumn('roles', 'string', array('length' => 255));
     $userTable->addColumn('created_at', 'datetime');
     // add an author_id to product
     $productTable->addForeignKeyConstraint($userTable, array('author_id'), array('id'));
     $schemaManager->dropAndCreateTable($userTable);
 }
开发者ID:vinodpanicker,项目名称:behat,代码行数:28,代码来源:SchemaManager.php

示例2: makeTableRepresentation

 public function makeTableRepresentation(DBAL\Schema\Table $table)
 {
     $table->addColumn('id', 'string', ['length' => 100]);
     $table->addColumn('content', 'string', ['length' => $this->length]);
     $table->addColumn('last_indexed', 'integer', ['length' => 50]);
     $table->addIndex(['id', 'content']);
 }
开发者ID:taproot,项目名称:librarian,代码行数:7,代码来源:StringIndex.php

示例3: doExecute

 protected function doExecute()
 {
     $this->step('Creating schema');
     $configuration = new \Firenote\Configuration\Yaml($this->rootPath . 'config');
     $app = new \Firenote\Application($configuration);
     $this->createDatabase($configuration);
     $schema = $app['db']->getSchemaManager();
     if (!$schema instanceof \Doctrine\DBAL\Schema\AbstractSchemaManager) {
         throw new \Exception();
     }
     if (!$schema->tablesExist('users')) {
         $this->writeln('<info>Creating table users ...</info>');
         $users = new Table('users');
         $users->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
         $users->setPrimaryKey(array('id'));
         $users->addColumn('username', 'string', array('length' => 32));
         $users->addUniqueIndex(array('username'));
         $users->addColumn('password', 'string', array('length' => 255));
         $users->addColumn('roles', 'string', array('length' => 255));
         $users->addColumn('avatar', 'string', array('length' => 512));
         $schema->createTable($users);
         $this->writeln('<info>Adding admin user (admin/foo) ...</info>');
         $this->writeln('<comment>Please change this dummy password !</comment>');
         $app['db']->insert('users', array('username' => 'admin', 'password' => '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg==', 'roles' => 'ROLE_ADMIN', 'avatar' => '/assets/firenote/avatars/avatar2.png'));
     } else {
         $this->writeln('Nothing to do !');
     }
 }
开发者ID:niktux,项目名称:firenote,代码行数:28,代码来源:DatabaseCreate.php

示例4: makeTableRepresentation

 public function makeTableRepresentation(DBAL\Schema\Table $table)
 {
     $table->addColumn('id', 'string', ['length' => 100]);
     $table->addColumn('datetime', 'datetime');
     $table->addColumn('last_indexed', 'integer', ['length' => 50]);
     $table->addIndex(['id', 'datetime']);
 }
开发者ID:taproot,项目名称:librarian,代码行数:7,代码来源:DateTimeIndex.php

示例5: exportCreateTable

 /**
  * Exports create table SQL.
  *
  * @return string
  */
 protected function exportCreateTable()
 {
     $table = new Table(self::TABLE_NAME, array(), array(), array(), false, array());
     $table->addColumn('id', 'string', array('length' => 2, 'notnull' => true));
     $table->setPrimaryKey(array('id'));
     $table->addColumn('value', 'string', array('length' => 64));
     return array_pop($this->getConnection()->getDatabasePlatform()->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES)) . ';' . PHP_EOL;
 }
开发者ID:umpirsky,项目名称:list-generator,代码行数:13,代码来源:SqlExporter.php

示例6: doIt

 public function doIt(Table $table, Schema $schema = null)
 {
     $table->addColumn("title", "string", ['notnull' => false]);
     $table->addColumn("sort", "integer", ['notnull' => false]);
     $table->addColumn("path", "string", ['notnull' => false]);
     $table->addColumn("level", "integer", ['notnull' => false]);
     $table->addColumn("parent_id", "integer", ['notnull' => false]);
     $table->addForeignKeyConstraint($table, array('parent_id'), array("id"), array("onUpdate" => "CASCADE"));
 }
开发者ID:dongww,项目名称:simple-db,代码行数:9,代码来源:TreeBehavior.php

示例7: testDropColumnConstraints

 /**
  * @group DBAL-255
  */
 public function testDropColumnConstraints()
 {
     $table = new Table('sqlsrv_drop_column');
     $table->addColumn('id', 'integer');
     $table->addColumn('todrop', 'decimal', array('default' => 10.2));
     $this->_sm->createTable($table);
     $diff = new TableDiff('sqlsrv_drop_column', array(), array(), array(new Column('todrop', Type::getType('decimal'))));
     $this->_sm->alterTable($diff);
     $columns = $this->_sm->listTableColumns('sqlsrv_drop_column');
     $this->assertEquals(1, count($columns));
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:14,代码来源:SQLServerSchemaManagerTest.php

示例8: testListTableColumnsWithFixedStringTypeColumn

 public function testListTableColumnsWithFixedStringTypeColumn()
 {
     $table = new Table('list_table_columns_char');
     $table->addColumn('id', 'integer', array('notnull' => true));
     $table->addColumn('test', 'string', array('fixed' => true));
     $table->setPrimaryKey(array('id'));
     $this->_sm->dropAndCreateTable($table);
     $columns = $this->_sm->listTableColumns('list_table_columns_char');
     $this->assertArrayHasKey('test', $columns);
     $this->assertTrue($columns['test']->getFixed());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:11,代码来源:SQLAnywhereSchemaManagerTest.php

示例9: testClobNoAlterTable

 /**
  * @group DDC-1737
  */
 public function testClobNoAlterTable()
 {
     $tableOld = new Table("test");
     $tableOld->addColumn('id', 'integer');
     $tableOld->addColumn('description', 'string', array('length' => 65536));
     $tableNew = clone $tableOld;
     $tableNew->setPrimaryKey(array('id'));
     $diff = $this->comparator->diffTable($tableOld, $tableNew);
     $sql = $this->platform->getAlterTableSQL($diff);
     $this->assertEquals(array('ALTER TABLE test ADD PRIMARY KEY (id)'), $sql);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:14,代码来源:MySQLSchemaTest.php

示例10: createTable

 public function createTable()
 {
     if ($this->isExistTable()) {
         return;
     }
     $table = new Table(self::TABLE_NAME);
     $table->addColumn('version', Type::STRING, array('length' => 255, 'notnull' => true, 'default' => ''));
     $table->addColumn('apply_at', Type::DATETIME, array('notnull' => false, 'default' => null));
     $table->setPrimaryKey(array('version'));
     $this->doctrine->getSchemaManager()->createTable($table);
 }
开发者ID:sickhye,项目名称:php-db-migrate,代码行数:11,代码来源:DbTable.php

示例11: createTable

 private function createTable(string $tableName) : Table
 {
     $table = new Table($tableName);
     $table->addColumn('aggregate_id', 'guid', ['notnull' => true]);
     $table->addColumn('occurred_on', 'datetime', ['notnull' => true]);
     $table->addColumn('name', 'string', ['notnull' => true]);
     $table->addColumn('event_class', 'string', ['notnull' => true]);
     $table->addColumn('event', 'text');
     $table->addIndex(['aggregate_id']);
     $table->addIndex(['occurred_on']);
     return $table;
 }
开发者ID:cocoders,项目名称:event-store-dbal-adapter,代码行数:12,代码来源:SchemaManager.php

示例12: getTableMetaData

 public static function getTableMetaData()
 {
     if (self::$schemaDetails === null) {
         $table = new Table('mock_temporal');
         $table->addColumn('slug_name', "string", array("length" => 150));
         $table->addColumn('enabled_from', "date", array());
         $table->addColumn('enabled_to', "date", array());
         $table->addColumn('posting_date', "date", array());
         self::$schemaDetails = $table;
     }
     return self::$schemaDetails;
 }
开发者ID:rayhan0421,项目名称:GeneralLedger,代码行数:12,代码来源:MockGateway.php

示例13: testSwitchPrimaryKeyColumns

 public function testSwitchPrimaryKeyColumns()
 {
     $tableOld = new Table("switch_primary_key_columns");
     $tableOld->addColumn('foo_id', 'integer');
     $tableOld->addColumn('bar_id', 'integer');
     $tableNew = clone $tableOld;
     $this->_sm->createTable($tableOld);
     $tableFetched = $this->_sm->listTableDetails("switch_primary_key_columns");
     $tableNew = clone $tableFetched;
     $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
     $comparator = new \Doctrine\DBAL\Schema\Comparator();
     $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:MySqlSchemaManagerTest.php

示例14: testColumnCollation

 public function testColumnCollation()
 {
     $table = new Schema\Table('test_collation');
     $table->addColumn('id', 'integer');
     $table->addColumn('text', 'text');
     $table->addColumn('foo', 'text')->setPlatformOption('collation', 'BINARY');
     $table->addColumn('bar', 'text')->setPlatformOption('collation', 'NOCASE');
     $this->_sm->dropAndCreateTable($table);
     $columns = $this->_sm->listTableColumns('test_collation');
     $this->assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
     $this->assertEquals('BINARY', $columns['text']->getPlatformOption('collation'));
     $this->assertEquals('BINARY', $columns['foo']->getPlatformOption('collation'));
     $this->assertEquals('NOCASE', $columns['bar']->getPlatformOption('collation'));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:14,代码来源:SqliteSchemaManagerTest.php

示例15: testUniquePrimaryKey

 public function testUniquePrimaryKey()
 {
     $keyTable = new Table("foo");
     $keyTable->addColumn("bar", "integer");
     $keyTable->addColumn("baz", "string");
     $keyTable->setPrimaryKey(array("bar"));
     $keyTable->addUniqueIndex(array("baz"));
     $oldTable = new Table("foo");
     $oldTable->addColumn("bar", "integer");
     $oldTable->addColumn("baz", "string");
     $c = new \Doctrine\DBAL\Schema\Comparator();
     $diff = $c->diffTable($oldTable, $keyTable);
     $sql = $this->_platform->getAlterTableSQL($diff);
     $this->assertEquals(array("ALTER TABLE foo ADD PRIMARY KEY (bar)", "CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)"), $sql);
 }
开发者ID:barbondev,项目名称:mysql4-doctrine-driver,代码行数:15,代码来源:MySQL4PlatformTest.php


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