• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Schema\Table类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: __construct

 public function __construct(TableInformation $parent, \Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column)
 {
     $this->table = $parent;
     foreach ($table->getForeignKeys() as $foreign) {
         if (in_array($column->getName(), $foreign->getColumns())) {
             $foreign_columns = $foreign->getForeignColumns();
             $this->foreignTable = $foreign->getForeignTableName();
             $this->foreignColumn = reset($foreign_columns);
             $this->isForeign = true;
         }
     }
     if ($primary_key = $table->getPrimaryKey()) {
         $this->isPrimary = in_array($column->getName(), $primary_key->getColumns());
     }
     $this->name = $column->getName();
     $this->type = $column->getType()->getName();
     $this->length = $column->getLength();
     $this->precision = $column->getPrecision();
     $this->default = $column->getDefault();
     $this->isNotNull = $column->getNotnull();
     $this->isUnsigned = $column->getUnsigned();
     $this->isFixed = $column->getFixed();
     $this->isAutoIncrement = $column->getAutoincrement();
     $this->comment = $column->getComment();
     if ($this->type === \Doctrine\DBAL\Types\Type::BLOB) {
         $this->length = min($this->bytesFromIni('post_max_size'), $this->bytesFromIni('upload_max_filesize'));
     }
 }
开发者ID:alanedwardes,项目名称:carbo,代码行数:28,代码来源:ColumnInformation.php


示例3: testGenerateTableWithAutoincrement

 public function testGenerateTableWithAutoincrement()
 {
     $table = new \Doctrine\DBAL\Schema\Table('autoinc_table');
     $column = $table->addColumn('id', 'integer');
     $column->setAutoincrement(true);
     $this->assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:7,代码来源:AbstractPostgreSqlPlatformTestCase.php


示例4: addColumns

 public function addColumns(\Doctrine\DBAL\Schema\Table $table, $columns)
 {
     foreach ($columns as $column) {
         $table->addColumn($column['name'], $column['type'], $column['options']);
     }
     return $table;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:7,代码来源:ArrayParser.php


示例5: testReservedColumnName

 public function testReservedColumnName()
 {
     $table = new Table("TABLE");
     $column = $table->addColumn('table', 'string');
     $this->validator->acceptColumn($table, $column);
     $this->assertEquals(array('Table TABLE column table keyword violations: MySQL'), $this->validator->getViolations());
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:7,代码来源:ReservedKeywordsValidatorTest.php


示例6: acceptForeignKey

 /**
  * @param Table $localTable
  * @param ForeignKeyConstraint $fkConstraint
  */
 public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
 {
     // Append the foreign key constraints SQL
     if ($this->_platform->supportsForeignKeyConstraints()) {
         $this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries, (array) $this->_platform->getCreateForeignKeySQL($fkConstraint, $localTable->getName()));
     }
 }
开发者ID:poulikov,项目名称:readlater,代码行数:11,代码来源:CreateSchemaSqlCollector.php


示例7: isTableNotIgnored

 /**
  * @param Table $table
  * @return bool
  */
 public function isTableNotIgnored(Table $table)
 {
     if (!$this->config->hasTableConfig($table->getName())) {
         return true;
     }
     return !$this->config->getTableConfig($table->getName())->isTableIgnored();
 }
开发者ID:digilist,项目名称:snakedumper,代码行数:11,代码来源:TableFilter.php


示例8: createTable

 private function createTable($name)
 {
     $table = new Schema\Table($this->tableName($name));
     $table->addColumn('id', Type::INTEGER, ['autoincrement' => true, 'unsigned' => true]);
     $table->setPrimaryKey(['id']);
     return $table;
 }
开发者ID:alanedwardes,项目名称:carbo,代码行数:7,代码来源:SchemaCurator.php


示例9: map

 /**
  * @param string          $schema
  * @param Table           $table
  * @param string          $name
  * @param FieldDefinition $definition
  */
 public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
 {
     $table->addColumn($name, 'float', ['notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'unique' => $definition->options()['unique'] ?? false]);
     if ($definition->options()['index'] ?? false) {
         $table->addIndex([$name]);
     }
 }
开发者ID:dumplie,项目名称:dumplie,代码行数:13,代码来源:FloatMapping.php


示例10: 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


示例11: testCreateTemporaryTableNotAutoCommitTransaction

 /**
  * @group DDC-1337
  * @return void
  */
 public function testCreateTemporaryTableNotAutoCommitTransaction()
 {
     if ($this->_conn->getDatabasePlatform()->getName() == 'sqlanywhere' || $this->_conn->getDatabasePlatform()->getName() == 'oracle') {
         $this->markTestSkipped("Test does not work on Oracle and SQL Anywhere.");
     }
     $platform = $this->_conn->getDatabasePlatform();
     $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
     $tempTable = $platform->getTemporaryTableName("my_temporary");
     $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
     $table = new Table("nontemporary");
     $table->addColumn("id", "integer");
     $table->setPrimaryKey(array('id'));
     foreach ($platform->getCreateTableSQL($table) as $sql) {
         $this->_conn->executeQuery($sql);
     }
     $this->_conn->beginTransaction();
     $this->_conn->insert("nontemporary", array("id" => 1));
     $this->_conn->exec($createTempTableSQL);
     $this->_conn->insert("nontemporary", array("id" => 2));
     $this->_conn->rollback();
     try {
         $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable));
     } catch (\Exception $e) {
     }
     $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
     $this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
 }
开发者ID:selimcr,项目名称:servigases,代码行数:31,代码来源:TemporaryTableTest.php


示例12: 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


示例13: map

 /**
  * @param string          $schema
  * @param Table           $table
  * @param string          $name
  * @param FieldDefinition $definition
  *
  * @throws DoctrineStorageException
  */
 public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
 {
     if (!$definition instanceof AssociationFieldDefinition) {
         throw DoctrineStorageException::invalidDefinition(AssociationFieldDefinition::class, $definition);
     }
     $table->addColumn($name, 'guid', ['notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'length' => $definition->options()['length'] ?? null, 'unique' => $definition->options()['unique'] ?? false]);
     $table->addForeignKeyConstraint($this->tableName($schema, $definition->typeSchema()->name()), [$name], ['id']);
 }
开发者ID:dumplie,项目名称:dumplie,代码行数:16,代码来源:AssociationMapping.php


示例14: buildTable

 /**
  * Get the table's schema object.
  *
  * @param Schema $schema
  * @param string $tableName
  *
  * @return \Doctrine\DBAL\Schema\Table
  */
 public function buildTable(Schema $schema, $tableName)
 {
     $this->table = $schema->createTable($tableName);
     $this->tableName = $this->table->getName();
     $this->addColumns();
     $this->addIndexes();
     $this->setPrimaryKey();
     return $this->table;
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:17,代码来源:BaseTable.php


示例15: addForeignKey

 /**
  * @param DBALTable $KeyTarget Foreign Key (Column: KeySource Name)
  * @param DBALTable $KeySource Foreign Data (Column: Id)
  */
 public function addForeignKey(DBALTable &$KeyTarget, DBALTable $KeySource)
 {
     if (!$this->Database->hasColumn($KeyTarget->getName(), $KeySource->getName())) {
         $KeyTarget->addColumn($KeySource->getName(), 'bigint');
         if ($this->Database->getPlatform()->supportsForeignKeyConstraints()) {
             $KeyTarget->addForeignKeyConstraint($KeySource, array($KeySource->getName()), array('Id'));
         }
     }
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:13,代码来源:Structure.php


示例16: _addTable

 /**
  * @param Table $table
  */
 protected function _addTable(Table $table)
 {
     $tableName = strtolower($table->getName());
     if (isset($this->_tables[$tableName])) {
         throw SchemaException::tableAlreadyExists($tableName);
     }
     $this->_tables[$tableName] = $table;
     $table->setSchemaConfig($this->_schemaConfig);
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:12,代码来源:Schema.php


示例17: renameColumn

 /**
  * Renames a column
  *
  * @param Schema   $schema
  * @param QueryBag $queries
  * @param Table    $table
  * @param string   $oldColumnName
  * @param string   $newColumnName
  */
 public function renameColumn(Schema $schema, QueryBag $queries, Table $table, $oldColumnName, $newColumnName)
 {
     $column = new Column(['column' => $table->getColumn($oldColumnName)]);
     $column->changeName($newColumnName);
     $diff = new TableDiff($table->getName());
     $diff->renamedColumns = [$oldColumnName => $column];
     $renameQuery = new SqlMigrationQuery($this->platform->getAlterTableSQL($diff));
     $queries->addQuery($renameQuery);
 }
开发者ID:ramunasd,项目名称:MigrationBundle,代码行数:18,代码来源:RenameExtension.php


示例18: __construct

 public function __construct(SchemaInformation $schema, \Doctrine\DBAL\Schema\Table $table)
 {
     $this->table = $table;
     $this->schema = $schema;
     $this->name = $table->getName();
     foreach ($this->table->getColumns() as $column) {
         $this->columns[$column->getName()] = new ColumnInformation($this, $table, $column);
     }
 }
开发者ID:alanedwardes,项目名称:carbo,代码行数:9,代码来源:TableInformation.php


示例19: addIndexes

 /**
  * Adds the missing indexes to the table
  *
  * @param \Doctrine\DBAL\Schema\Table $table Table object
  * @return \Doctrine\DBAL\Schema\Table Updated table object
  */
 protected function addIndexes(\Doctrine\DBAL\Schema\Table $table)
 {
     $indexes = array('idx_ezpus_langid' => array('langid'), 'idx_ezpus_status_ln_fn' => array('status', 'lastname', 'firstname'), 'idx_ezpus_status_ad1_ad2' => array('status', 'address1', 'address2'), 'idx_ezpus_status_postal_city' => array('status', 'postal', 'city'), 'idx_ezpus_lastname' => array('lastname'), 'idx_ezpus_address1' => array('address1'), 'idx_ezpus_postal' => array('postal'), 'idx_ezpus_city' => array('city'));
     foreach ($indexes as $name => $def) {
         if ($table->hasIndex($name) === false) {
             $table->addIndex($def, $name);
         }
     }
     return $table;
 }
开发者ID:aimeos,项目名称:ai-ezpublish,代码行数:16,代码来源:EzuserAddAddress.php


示例20: setOwnerCascadeDelete

 /**
  * @param Schema $schema
  * @param Table $table
  * @param string $keyName
  */
 protected function setOwnerCascadeDelete(Schema $schema, Table $table, $keyName)
 {
     foreach ($table->getForeignKeys() as $foreignKey) {
         if ($foreignKey->getLocalColumns() == ['owner_id']) {
             $table->removeForeignKey($foreignKey->getName());
             $table->addForeignKeyConstraint($schema->getTable('orocrm_contact'), ['owner_id'], ['id'], ['onDelete' => 'CASCADE', 'onUpdate' => null], $keyName);
             break;
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:15,代码来源:OroCRMContactBundle.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Types\ConversionException类代码示例发布时间:2022-05-23
下一篇:
PHP Schema\Sequence类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap