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


PHP Table::isIdGeneratorIdentity方法代码示例

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


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

示例1: testIdGeneratorType

 public function testIdGeneratorType()
 {
     $table = new Table("foo");
     $table->setIdGeneratorType(Table::ID_IDENTITY);
     $this->assertTrue($table->isIdGeneratorIdentity());
     $table->setIdGeneratorType(Table::ID_SEQUENCE);
     $this->assertTrue($table->isIdGeneratorSequence());
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:8,代码来源:TableTest.php

示例2: getCreateTableSQL

 /**
  * Gets the SQL statement(s) to create a table with the specified name, columns and constraints
  * on this platform.
  *
  * @param string $table The name of the table.
  * @param int $createFlags
  * @return array The sequence of SQL statements.
  */
 public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES)
 {
     if (!is_int($createFlags)) {
         throw new \InvalidArgumentException("Second argument of AbstractPlatform::getCreateTableSQL() has to be integer.");
     }
     if (count($table->getColumns()) == 0) {
         throw DBALException::noColumnsSpecifiedForTable($table->getName());
     }
     $tableName = $table->getName();
     $options = $table->getOptions();
     $options['uniqueConstraints'] = array();
     $options['indexes'] = array();
     $options['primary'] = array();
     if (($createFlags & self::CREATE_INDEXES) > 0) {
         foreach ($table->getIndexes() as $index) {
             /* @var $index Index */
             if ($index->isPrimary()) {
                 $options['primary'] = $index->getColumns();
             } else {
                 $options['indexes'][$index->getName()] = $index;
             }
         }
     }
     $columns = array();
     foreach ($table->getColumns() as $column) {
         /* @var \Doctrine\DBAL\Schema\Column $column */
         $columnData = array();
         $columnData['name'] = $column->getName();
         $columnData['type'] = $column->getType();
         $columnData['length'] = $column->getLength();
         $columnData['notnull'] = $column->getNotNull();
         $columnData['unique'] = $column->hasPlatformOption("unique") ? $column->getPlatformOption('unique') : false;
         $columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption('version') : false;
         if (strtolower($columnData['type']) == "string" && $columnData['length'] === null) {
             $columnData['length'] = 255;
         }
         $columnData['precision'] = $column->getPrecision();
         $columnData['scale'] = $column->getScale();
         $columnData['default'] = $column->getDefault();
         $columnData['columnDefinition'] = $column->getColumnDefinition();
         if (in_array($column->getName(), $options['primary'])) {
             $columnData['primary'] = true;
             if ($table->isIdGeneratorIdentity()) {
                 $columnData['autoincrement'] = true;
             }
         }
         $columns[$columnData['name']] = $columnData;
     }
     if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) {
         $options['foreignKeys'] = array();
         foreach ($table->getForeignKeys() as $fkConstraint) {
             $options['foreignKeys'][] = $fkConstraint;
         }
     }
     return $this->_getCreateTableSQL($tableName, $columns, $options);
 }
开发者ID:skoop,项目名称:doctrine2,代码行数:64,代码来源:AbstractPlatform.php


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