当前位置: 首页>>代码示例>>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;未经允许,请勿转载。