當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Table::changeColumn方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Schema\Table::changeColumn方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::changeColumn方法的具體用法?PHP Table::changeColumn怎麽用?PHP Table::changeColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Schema\Table的用法示例。


在下文中一共展示了Table::changeColumn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDoctrineColumnForChange

 /**
  * @param \Doctrine\DBAL\Schema\Table $table
  * @param \Illuminate\Support\Fluent $fluent
  * @return \Doctrine\DBAL\Schema\Column
  */
 protected function getDoctrineColumnForChange(Table $table, Fluent $fluent)
 {
     return $table->changeColumn($fluent['name'], $this->getDoctrineColumnChangeOptions($fluent))->getColumn($fluent['name']);
 }
開發者ID:darrengopower,項目名稱:framework,代碼行數:9,代碼來源:Grammar.php

示例2: gatherColumn

 /**
  * Creates a column definition as required by the DBAL from an ORM field mapping definition.
  *
  * @param ClassMetadata $class   The class that owns the field mapping.
  * @param array         $mapping The field mapping.
  * @param Table         $table
  *
  * @return array The portable column definition as required by the DBAL.
  */
 private function gatherColumn($class, array $mapping, Table $table)
 {
     $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
     $columnType = $mapping['type'];
     $options = array();
     $options['length'] = isset($mapping['length']) ? $mapping['length'] : null;
     $options['notnull'] = isset($mapping['nullable']) ? !$mapping['nullable'] : true;
     if ($class->isInheritanceTypeSingleTable() && count($class->parentClasses) > 0) {
         $options['notnull'] = false;
     }
     $options['platformOptions'] = array();
     $options['platformOptions']['version'] = $class->isVersioned && $class->versionField == $mapping['fieldName'] ? true : false;
     if (strtolower($columnType) == 'string' && $options['length'] === null) {
         $options['length'] = 255;
     }
     if (isset($mapping['precision'])) {
         $options['precision'] = $mapping['precision'];
     }
     if (isset($mapping['scale'])) {
         $options['scale'] = $mapping['scale'];
     }
     if (isset($mapping['default'])) {
         $options['default'] = $mapping['default'];
     }
     if (isset($mapping['columnDefinition'])) {
         $options['columnDefinition'] = $mapping['columnDefinition'];
     }
     if (isset($mapping['options'])) {
         $knownOptions = array('comment', 'unsigned', 'fixed', 'default');
         foreach ($knownOptions as $knownOption) {
             if (array_key_exists($knownOption, $mapping['options'])) {
                 $options[$knownOption] = $mapping['options'][$knownOption];
                 unset($mapping['options'][$knownOption]);
             }
         }
         $options['customSchemaOptions'] = $mapping['options'];
     }
     if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
         $options['autoincrement'] = true;
     }
     if ($class->isInheritanceTypeJoined() && $class->name != $class->rootEntityName) {
         $options['autoincrement'] = false;
     }
     if ($table->hasColumn($columnName)) {
         // required in some inheritance scenarios
         $table->changeColumn($columnName, $options);
     } else {
         $table->addColumn($columnName, $columnType, $options);
     }
     $isUnique = isset($mapping['unique']) ? $mapping['unique'] : false;
     if ($isUnique) {
         $table->addUniqueIndex(array($columnName));
     }
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:63,代碼來源:SchemaTool.php


注:本文中的Doctrine\DBAL\Schema\Table::changeColumn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。