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


PHP Schema\Table类代码示例

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


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


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