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


PHP Column::setPlatformOption方法代碼示例

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


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

示例1: _getPortableTableColumnDefinition

 /**
  * {@inheritdoc}
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $dbType = strtolower($tableColumn['DATA_TYPE']);
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     $type = $this->extractDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
     $tableColumn['COLUMN_COMMENT'] = $this->removeDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
     $options = array('notnull' => !(bool) $tableColumn['IS_NULLABLE'], 'length' => (int) $tableColumn['CHARACTER_MAXIMUM_LENGTH'], 'default' => isset($tableColumn['COLUMN_DEFAULT']) ? $tableColumn['COLUMN_DEFAULT'] : null, 'autoincrement' => (bool) $tableColumn['IS_AUTO_INCREMENT'], 'scale' => (int) $tableColumn['NUMERIC_SCALE'], 'precision' => (int) $tableColumn['NUMERIC_PRECISION'], 'comment' => isset($tableColumn['COLUMN_COMMENT']) && '' !== $tableColumn['COLUMN_COMMENT'] ? $tableColumn['COLUMN_COMMENT'] : null);
     $column = new Column($tableColumn['COLUMN_NAME'], Type::getType($type), $options);
     if (!empty($tableColumn['COLLATION_NAME'])) {
         $column->setPlatformOption('collation', $tableColumn['COLLATION_NAME']);
     }
     return $column;
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:16,代碼來源:DrizzleSchemaManager.php

示例2: _getPortableTableColumnDefinition

 /**
  * {@inheritdoc}
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $dbType = strtok($tableColumn['type'], '(), ');
     $fixed = null;
     $length = (int) $tableColumn['length'];
     $default = $tableColumn['default'];
     if (!isset($tableColumn['name'])) {
         $tableColumn['name'] = '';
     }
     while ($default != ($default2 = preg_replace("/^\\((.*)\\)\$/", '$1', $default))) {
         $default = trim($default2, "'");
         if ($default == 'getdate()') {
             $default = $this->_platform->getCurrentTimestampSQL();
         }
     }
     switch ($dbType) {
         case 'nchar':
         case 'nvarchar':
         case 'ntext':
             // Unicode data requires 2 bytes per character
             $length = $length / 2;
             break;
         case 'varchar':
             // TEXT type is returned as VARCHAR(MAX) with a length of -1
             if ($length == -1) {
                 $dbType = 'text';
             }
             break;
     }
     if ('char' === $dbType || 'nchar' === $dbType || 'binary' === $dbType) {
         $fixed = true;
     }
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
     $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
     $options = array('length' => $length == 0 || !in_array($type, array('text', 'string')) ? null : $length, 'unsigned' => false, 'fixed' => (bool) $fixed, 'default' => $default !== 'NULL' ? $default : null, 'notnull' => (bool) $tableColumn['notnull'], 'scale' => $tableColumn['scale'], 'precision' => $tableColumn['precision'], 'autoincrement' => (bool) $tableColumn['autoincrement'], 'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null);
     $column = new Column($tableColumn['name'], Type::getType($type), $options);
     if (isset($tableColumn['collation']) && $tableColumn['collation'] !== 'NULL') {
         $column->setPlatformOption('collation', $tableColumn['collation']);
     }
     return $column;
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:45,代碼來源:SQLServerSchemaManager.php

示例3: _getPortableTableColumnDefinition


//.........這裏部分代碼省略.........
     }
     $matches = array();
     $autoincrement = false;
     if (preg_match("/^nextval\\('(.*)'(::.*)?\\)\$/", $tableColumn['default'], $matches)) {
         $tableColumn['sequence'] = $matches[1];
         $tableColumn['default'] = null;
         $autoincrement = true;
     }
     if (preg_match("/^'(.*)'::.*\$/", $tableColumn['default'], $matches)) {
         $tableColumn['default'] = $matches[1];
     }
     if (stripos($tableColumn['default'], 'NULL') === 0) {
         $tableColumn['default'] = null;
     }
     $length = isset($tableColumn['length']) ? $tableColumn['length'] : null;
     if ($length == '-1' && isset($tableColumn['atttypmod'])) {
         $length = $tableColumn['atttypmod'] - 4;
     }
     if ((int) $length <= 0) {
         $length = null;
     }
     $fixed = null;
     if (!isset($tableColumn['name'])) {
         $tableColumn['name'] = '';
     }
     $precision = null;
     $scale = null;
     $dbType = strtolower($tableColumn['type']);
     if (strlen($tableColumn['domain_type']) && !$this->_platform->hasDoctrineTypeMappingFor($tableColumn['type'])) {
         $dbType = strtolower($tableColumn['domain_type']);
         $tableColumn['complete_type'] = $tableColumn['domain_complete_type'];
     }
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
     $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
     switch ($dbType) {
         case 'smallint':
         case 'int2':
             $length = null;
             break;
         case 'int':
         case 'int4':
         case 'integer':
             $length = null;
             break;
         case 'bigint':
         case 'int8':
             $length = null;
             break;
         case 'bool':
         case 'boolean':
             if ($tableColumn['default'] === 'true') {
                 $tableColumn['default'] = true;
             }
             if ($tableColumn['default'] === 'false') {
                 $tableColumn['default'] = false;
             }
             $length = null;
             break;
         case 'text':
             $fixed = false;
             break;
         case 'varchar':
         case 'interval':
         case '_varchar':
             $fixed = false;
             break;
         case 'char':
         case 'bpchar':
             $fixed = true;
             break;
         case 'float':
         case 'float4':
         case 'float8':
         case 'double':
         case 'double precision':
         case 'real':
         case 'decimal':
         case 'money':
         case 'numeric':
             if (preg_match('([A-Za-z]+\\(([0-9]+)\\,([0-9]+)\\))', $tableColumn['complete_type'], $match)) {
                 $precision = $match[1];
                 $scale = $match[2];
                 $length = null;
             }
             break;
         case 'year':
             $length = null;
             break;
     }
     if ($tableColumn['default'] && preg_match("('([^']+)'::)", $tableColumn['default'], $match)) {
         $tableColumn['default'] = $match[1];
     }
     $options = array('length' => $length, 'notnull' => (bool) $tableColumn['isnotnull'], 'default' => $tableColumn['default'], 'primary' => (bool) ($tableColumn['pri'] == 't'), 'precision' => $precision, 'scale' => $scale, 'fixed' => $fixed, 'unsigned' => false, 'autoincrement' => $autoincrement, 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null);
     $column = new Column($tableColumn['field'], Type::getType($type), $options);
     if (isset($tableColumn['collation']) && !empty($tableColumn['collation'])) {
         $column->setPlatformOption('collation', $tableColumn['collation']);
     }
     return $column;
 }
開發者ID:betes-curieuses-design,項目名稱:ElieJosiePhotographie,代碼行數:101,代碼來源:PostgreSqlSchemaManager.php

示例4: _getPortableTableColumnDefinition

 /**
  * {@inheritdoc}
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
     $dbType = strtolower($tableColumn['type']);
     $dbType = strtok($dbType, '(), ');
     if (isset($tableColumn['length'])) {
         $length = $tableColumn['length'];
     } else {
         $length = strtok('(), ');
     }
     $fixed = null;
     if (!isset($tableColumn['name'])) {
         $tableColumn['name'] = '';
     }
     $scale = null;
     $precision = null;
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     // In cases where not connected to a database DESCRIBE $table does not return 'Comment'
     if (isset($tableColumn['comment'])) {
         $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
         $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
     }
     switch ($dbType) {
         case 'char':
         case 'binary':
             $fixed = true;
             break;
         case 'float':
         case 'double':
         case 'real':
         case 'numeric':
         case 'decimal':
             if (preg_match('([A-Za-z]+\\(([0-9]+)\\,([0-9]+)\\))', $tableColumn['type'], $match)) {
                 $precision = $match[1];
                 $scale = $match[2];
                 $length = null;
             }
             break;
         case 'tinytext':
             $length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT;
             break;
         case 'text':
             $length = MySqlPlatform::LENGTH_LIMIT_TEXT;
             break;
         case 'mediumtext':
             $length = MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT;
             break;
         case 'tinyblob':
             $length = MySqlPlatform::LENGTH_LIMIT_TINYBLOB;
             break;
         case 'blob':
             $length = MySqlPlatform::LENGTH_LIMIT_BLOB;
             break;
         case 'mediumblob':
             $length = MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB;
             break;
         case 'tinyint':
         case 'smallint':
         case 'mediumint':
         case 'int':
         case 'integer':
         case 'bigint':
         case 'year':
             $length = null;
             break;
     }
     $length = (int) $length == 0 ? null : (int) $length;
     $options = array('length' => $length, 'unsigned' => (bool) (strpos($tableColumn['type'], 'unsigned') !== false), 'fixed' => (bool) $fixed, 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null, 'notnull' => (bool) ($tableColumn['null'] != 'YES'), 'scale' => null, 'precision' => null, 'autoincrement' => (bool) (strpos($tableColumn['extra'], 'auto_increment') !== false), 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null);
     if ($scale !== null && $precision !== null) {
         $options['scale'] = $scale;
         $options['precision'] = $precision;
     }
     $column = new Column($tableColumn['field'], Type::getType($type), $options);
     if (isset($tableColumn['collation'])) {
         $column->setPlatformOption('collation', $tableColumn['collation']);
     }
     return $column;
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:81,代碼來源:MySqlSchemaManager.php

示例5: parseFieldOpts

 protected static function parseFieldOpts(Schema $schema, Column $field, SimpleXMLElement $xOptParent, AbstractPlatform $platform)
 {
     $opts = static::getOptArray($xOptParent, $platform);
     foreach ($opts as $name => $value) {
         $field->setPlatformOption($name, $value);
     }
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:7,代碼來源:Parser.php


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