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


PHP AbstractPlatform::getCreateTableSQL方法代码示例

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


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

示例1: processQueueCallback

 /**
  * ->processQueueCallback(function (\Dja\Db\Model\Metadata $metadata, \Doctrine\DBAL\Schema\Table $table, array $sql, \Doctrine\DBAL\Connection $db) {})
  * @param callable|\Closure $callBack
  */
 public function processQueueCallback(\Closure $callBack)
 {
     $callbackQueue = [];
     while (count($this->generateQueue)) {
         $modelName = array_shift($this->generateQueue);
         try {
             /** @var Metadata $metadata */
             $metadata = $modelName::metadata();
             $tblName = $metadata->getDbTableName();
             if ($this->db->getSchemaManager()->tablesExist($tblName)) {
                 continue;
             }
             if (isset($this->generated[$tblName])) {
                 continue;
             }
             $table = $this->metadataToTable($metadata);
             $this->generated[$tblName] = 1;
             $sql = $this->dp->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES);
             array_unshift($callbackQueue, [$metadata, $table, $sql]);
             $fks = $table->getForeignKeys();
             if (count($fks)) {
                 $sql = [];
                 foreach ($fks as $fk) {
                     $sql[] = $this->dp->getCreateForeignKeySQL($fk, $table);
                 }
                 array_push($callbackQueue, [$metadata, $table, $sql]);
             }
         } catch (\Exception $e) {
             pr($e->__toString());
         }
     }
     foreach ($callbackQueue as $args) {
         $callBack($args[0], $args[1], $args[2], $this->db);
     }
 }
开发者ID:buldezir,项目名称:dja_orm,代码行数:39,代码来源:Creation.php

示例2: dumpTableStructure

 /**
  * @param Table[] $tables
  */
 public function dumpTableStructure(array $tables)
 {
     $this->logger->info('Dumping table structure');
     foreach ($tables as $table) {
         $structure = $this->platform->getCreateTableSQL($table);
         $this->dumpOutput->writeln(implode(";\n", $structure) . ';');
     }
 }
开发者ID:digilist,项目名称:snakedumper,代码行数:11,代码来源:StructureDumper.php

示例3: testQuotedColumnInForeignKeyPropagation

 /**
  * @group DBAL-374
  */
 public function testQuotedColumnInForeignKeyPropagation()
 {
     $table = new Table('`quoted`');
     $table->addColumn('create', 'string');
     $table->addColumn('foo', 'string');
     $table->addColumn('`bar`', 'string');
     // Foreign table with reserved keyword as name (needs quotation).
     $foreignTable = new Table('foreign');
     $foreignTable->addColumn('create', 'string');
     // Foreign column with reserved keyword as name (needs quotation).
     $foreignTable->addColumn('bar', 'string');
     // Foreign column with non-reserved keyword as name (does not need quotation).
     $foreignTable->addColumn('`foo-bar`', 'string');
     // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
     $table->addForeignKeyConstraint($foreignTable, array('create', 'foo', '`bar`'), array('create', 'bar', '`foo-bar`'), array(), 'FK_WITH_RESERVED_KEYWORD');
     // Foreign table with non-reserved keyword as name (does not need quotation).
     $foreignTable = new Table('foo');
     $foreignTable->addColumn('create', 'string');
     // Foreign column with reserved keyword as name (needs quotation).
     $foreignTable->addColumn('bar', 'string');
     // Foreign column with non-reserved keyword as name (does not need quotation).
     $foreignTable->addColumn('`foo-bar`', 'string');
     // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
     $table->addForeignKeyConstraint($foreignTable, array('create', 'foo', '`bar`'), array('create', 'bar', '`foo-bar`'), array(), 'FK_WITH_NON_RESERVED_KEYWORD');
     // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
     $foreignTable = new Table('`foo-bar`');
     $foreignTable->addColumn('create', 'string');
     // Foreign column with reserved keyword as name (needs quotation).
     $foreignTable->addColumn('bar', 'string');
     // Foreign column with non-reserved keyword as name (does not need quotation).
     $foreignTable->addColumn('`foo-bar`', 'string');
     // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
     $table->addForeignKeyConstraint($foreignTable, array('create', 'foo', '`bar`'), array('create', 'bar', '`foo-bar`'), array(), 'FK_WITH_INTENDED_QUOTATION');
     $sql = $this->_platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS);
     $this->assertEquals($this->getQuotedColumnInForeignKeySQL(), $sql);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:39,代码来源:AbstractPlatformTestCase.php

示例4: _toSql

 /**
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  * @param boolean                                   $saveMode
  *
  * @return array
  */
 protected function _toSql(AbstractPlatform $platform, $saveMode = false)
 {
     $sql = array();
     if ($platform->supportsSchemas()) {
         foreach ($this->newNamespaces as $newNamespace) {
             $sql[] = $platform->getCreateSchemaSQL($newNamespace);
         }
     }
     if ($platform->supportsForeignKeyConstraints() && $saveMode == false) {
         foreach ($this->orphanedForeignKeys as $orphanedForeignKey) {
             $sql[] = $platform->getDropForeignKeySQL($orphanedForeignKey, $orphanedForeignKey->getLocalTableName());
         }
     }
     if ($platform->supportsSequences() == true) {
         foreach ($this->changedSequences as $sequence) {
             $sql[] = $platform->getAlterSequenceSQL($sequence);
         }
         if ($saveMode === false) {
             foreach ($this->removedSequences as $sequence) {
                 $sql[] = $platform->getDropSequenceSQL($sequence);
             }
         }
         foreach ($this->newSequences as $sequence) {
             $sql[] = $platform->getCreateSequenceSQL($sequence);
         }
     }
     $foreignKeySql = array();
     foreach ($this->newTables as $table) {
         $sql = array_merge($sql, $platform->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES));
         if ($platform->supportsForeignKeyConstraints()) {
             foreach ($table->getForeignKeys() as $foreignKey) {
                 $foreignKeySql[] = $platform->getCreateForeignKeySQL($foreignKey, $table);
             }
         }
     }
     $sql = array_merge($sql, $foreignKeySql);
     if ($saveMode === false) {
         foreach ($this->removedTables as $table) {
             $sql[] = $platform->getDropTableSQL($table);
         }
     }
     foreach ($this->changedTables as $tableDiff) {
         $sql = array_merge($sql, $platform->getAlterTableSQL($tableDiff));
     }
     return $sql;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:52,代码来源:SchemaDiff.php

示例5: createTable

 /**
  * Create a new table.
  *
  * @param Table $table
  * @param int $createFlags
  */
 public function createTable(Table $table)
 {
     $createFlags = AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS;
     $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
 }
开发者ID:jff15,项目名称:travelbot,代码行数:11,代码来源:AbstractSchemaManager.php

示例6: acceptTable

 /**
  * Generate DDL Statements to create the accepted table with all its dependencies.
  *
  * @param Table $table
  */
 public function acceptTable(Table $table)
 {
     $namespace = $this->getNamespace($table);
     $this->_createTableQueries[$namespace] = array_merge($this->_createTableQueries[$namespace], $this->_platform->getCreateTableSQL($table));
 }
开发者ID:jeanlopes,项目名称:mostra-ifrs-poa,代码行数:10,代码来源:CreateSchemaSqlCollector.php

示例7: getCreateTableSQL

 /**
  * {@inheritDoc}
  */
 public function getCreateTableSQL(Table $table, $createFlags = null)
 {
     $createFlags = null === $createFlags ? self::CREATE_INDEXES | self::CREATE_FOREIGNKEYS : $createFlags;
     return parent::getCreateTableSQL($table, $createFlags);
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:8,代码来源:SqlitePlatform.php

示例8: acceptTable

 /**
  * {@inheritdoc}
  */
 public function acceptTable(Table $table)
 {
     $this->createTableQueries = array_merge($this->createTableQueries, (array) $this->platform->getCreateTableSQL($table));
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:7,代码来源:CreateSchemaSqlCollector.php

示例9: getCreateTableSQL

 /**
  * @override
  */
 public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES)
 {
     $sql = parent::getCreateTableSQL($table, $createFlags);
     $primary = array();
     foreach ($table->getIndexes() as $index) {
         /* @var $index Index */
         if ($index->isPrimary()) {
             $primary = $index->getColumns();
         }
     }
     if (count($primary) === 1) {
         foreach ($table->getForeignKeys() as $definition) {
             $columns = $definition->getLocalColumns();
             if (count($columns) === 1 && in_array($columns[0], $primary)) {
                 $sql[0] = str_replace(' IDENTITY', '', $sql[0]);
             }
         }
     }
     return $sql;
 }
开发者ID:jff15,项目名称:travelbot,代码行数:23,代码来源:MsSqlPlatform.php


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