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


PHP Table::getOptions方法代码示例

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


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

示例1: addTable

 /**
  * Add a table object to the schema
  *
  * @param Table $table table object to add
  *
  * @return void
  */
 public function addTable(Table $table)
 {
     //echo '<h2>addTable()</h2>';
     try {
         $name = $table->getName();
         $len = strlen($this->xPrefix);
         if (substr_compare($name, $this->xPrefix, 0, $len) === 0) {
             $name = substr($name, $len);
             if (empty($this->tableList) || in_array($name, $this->tableList)) {
                 $idGeneratorType = 0;
                 // how should we handle this?
                 $newtable = new Table($name, $table->getColumns(), $table->getIndexes(), $table->getForeignKeys(), $idGeneratorType, $table->getOptions());
                 $this->_addTable($newtable);
             }
         }
         //Debug::dump($table);
     } catch (\Exception $e) {
         \Xoops::getInstance()->events()->triggerEvent('core.exception', $e);
         throw $e;
     }
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:28,代码来源:PrefixStripper.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->getQuotedName($this);
     $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;
             }
         }
     }
     $columnSql = array();
     $columns = array();
     foreach ($table->getColumns() as $column) {
         /* @var \Doctrine\DBAL\Schema\Column $column */
         if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaCreateTableColumn)) {
             $eventArgs = new SchemaCreateTableColumnEventArgs($column, $table, $this);
             $this->_eventManager->dispatchEvent(Events::onSchemaCreateTableColumn, $eventArgs);
             $columnSql = array_merge($columnSql, $eventArgs->getSql());
             if ($eventArgs->isDefaultPrevented()) {
                 continue;
             }
         }
         $columnData = array();
         $columnData['name'] = $column->getQuotedName($this);
         $columnData['type'] = $column->getType();
         $columnData['length'] = $column->getLength();
         $columnData['notnull'] = $column->getNotNull();
         $columnData['fixed'] = $column->getFixed();
         $columnData['unique'] = false;
         // TODO: what do we do about this?
         $columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption('version') : false;
         if (strtolower($columnData['type']) == "string" && $columnData['length'] === null) {
             $columnData['length'] = 255;
         }
         $columnData['unsigned'] = $column->getUnsigned();
         $columnData['precision'] = $column->getPrecision();
         $columnData['scale'] = $column->getScale();
         $columnData['default'] = $column->getDefault();
         $columnData['columnDefinition'] = $column->getColumnDefinition();
         $columnData['autoincrement'] = $column->getAutoincrement();
         $columnData['comment'] = $this->getColumnComment($column);
         if (in_array($column->getName(), $options['primary'])) {
             $columnData['primary'] = true;
         }
         $columns[$columnData['name']] = $columnData;
     }
     if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) {
         $options['foreignKeys'] = array();
         foreach ($table->getForeignKeys() as $fkConstraint) {
             $options['foreignKeys'][] = $fkConstraint;
         }
     }
     if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaCreateTable)) {
         $eventArgs = new SchemaCreateTableEventArgs($table, $columns, $options, $this);
         $this->_eventManager->dispatchEvent(Events::onSchemaCreateTable, $eventArgs);
         if ($eventArgs->isDefaultPrevented()) {
             return array_merge($eventArgs->getSql(), $columnSql);
         }
     }
     $sql = $this->_getCreateTableSQL($tableName, $columns, $options);
     if ($this->supportsCommentOnStatement()) {
         foreach ($table->getColumns() as $column) {
             if ($this->getColumnComment($column)) {
                 $sql[] = $this->getCommentOnColumnSQL($tableName, $column->getName(), $this->getColumnComment($column));
             }
         }
     }
     return array_merge($sql, $columnSql);
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:90,代码来源:AbstractPlatform.php

示例3: renameTableSchema

 /**
  * @param \Doctrine\DBAL\Schema\Table $table
  * @param string $newName
  * @return \Doctrine\DBAL\Schema\Table
  */
 protected function renameTableSchema(Table $table, $newName)
 {
     /**
      * @var \Doctrine\DBAL\Schema\Index[] $indexes
      */
     $indexes = $table->getIndexes();
     $newIndexes = array();
     foreach ($indexes as $index) {
         if ($index->isPrimary()) {
             // do not rename primary key
             $indexName = $index->getName();
         } else {
             // avoid conflicts in index names
             $indexName = $this->config->getSystemValue('dbtableprefix', 'oc_') . $this->random->generate(13, ISecureRandom::CHAR_LOWER);
         }
         $newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
     }
     // foreign keys are not supported so we just set it to an empty array
     return new Table($newName, $table->getColumns(), $newIndexes, array(), 0, $table->getOptions());
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:25,代码来源:Migrator.php

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

示例5: getCreateTableSQL

 /**
  * {@inheritDoc}
  * Gets the SQL statement(s) to create a table with the specified name, columns and constraints
  * on this platform.
  *
  * @param Table $table The name of the table.
  * @param integer $createFlags
  *
  * @return array The sequence of SQL statements.
  */
 public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES)
 {
     if (!is_int($createFlags)) {
         $msg = "Second argument of CratePlatform::getCreateTableSQL() has to be integer.";
         throw new \InvalidArgumentException($msg);
     }
     if (count($table->getColumns()) === 0) {
         throw DBALException::noColumnsSpecifiedForTable($table->getName());
     }
     $tableName = $table->getQuotedName($this);
     $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()) {
                 $platform = $this;
                 $options['primary'] = array_map(function ($columnName) use($table, $platform) {
                     return $table->getColumn($columnName)->getQuotedName($platform);
                 }, $index->getColumns());
                 $options['primary_index'] = $index;
             } else {
                 $options['indexes'][$index->getName()] = $index;
             }
         }
     }
     $columnSql = array();
     $columns = array();
     foreach ($table->getColumns() as $column) {
         if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaCreateTableColumn)) {
             $eventArgs = new SchemaCreateTableColumnEventArgs($column, $table, $this);
             $this->_eventManager->dispatchEvent(Events::onSchemaCreateTableColumn, $eventArgs);
             $columnSql = array_merge($columnSql, $eventArgs->getSql());
             if ($eventArgs->isDefaultPrevented()) {
                 continue;
             }
         }
         $columns[$column->getQuotedName($this)] = $this->prepareColumnData($column, $options['primary']);
     }
     if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaCreateTable)) {
         $eventArgs = new SchemaCreateTableEventArgs($table, $columns, $options, $this);
         $this->_eventManager->dispatchEvent(Events::onSchemaCreateTable, $eventArgs);
         if ($eventArgs->isDefaultPrevented()) {
             return array_merge($eventArgs->getSql(), $columnSql);
         }
     }
     $sql = $this->_getCreateTableSQL($tableName, $columns, $options);
     if ($this->supportsCommentOnStatement()) {
         foreach ($table->getColumns() as $column) {
             if ($this->getColumnComment($column)) {
                 $sql[] = $this->getCommentOnColumnSQL($tableName, $column->getName(), $this->getColumnComment($column));
             }
         }
     }
     return array_merge($sql, $columnSql);
 }
开发者ID:crate,项目名称:crate-dbal,代码行数:68,代码来源:CratePlatform.php

示例6: renameTableSchema

 /**
  * @param \Doctrine\DBAL\Schema\Table $table
  * @param string $newName
  * @return \Doctrine\DBAL\Schema\Table
  */
 protected function renameTableSchema(Table $table, $newName)
 {
     /**
      * @var \Doctrine\DBAL\Schema\Index[] $indexes
      */
     $indexes = $table->getIndexes();
     $newIndexes = array();
     foreach ($indexes as $index) {
         if ($index->isPrimary()) {
             // do not rename primary key
             $indexName = $index->getName();
         } else {
             // avoid conflicts in index names
             $indexName = 'oc_' . \OCP\Util::generateRandomBytes(13);
         }
         $newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
     }
     // foreign keys are not supported so we just set it to an empty array
     return new Table($newName, $table->getColumns(), $newIndexes, array(), 0, $table->getOptions());
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:25,代码来源:migrator.php

示例7: compareTable

 /**
  * Tests whether both tables are equal.
  *
  * @param Table $expected
  * @param Table $actual
  */
 protected function compareTable(Table $expected, Table $actual)
 {
     $this->assertEquals($expected->getColumns(), $actual->getColumns());
     $this->assertEquals($expected->getOptions(), $actual->getOptions());
 }
开发者ID:asev,项目名称:ConnectionsBundle,代码行数:11,代码来源:TableManagerTest.php

示例8: acceptTable

 /**
  * Accept a table
  *
  * @param Table $table a table object
  * 
  * @return void
  */
 public function acceptTable(Table $table)
 {
     $this->schemaArray['tables'][$table->getName()]['options'] = $table->getOptions();
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:11,代码来源:ExportVisitor.php


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