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


PHP Column::setCustomSchemaOption方法代码示例

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


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

示例1: testCompareChangedColumns_ChangeCustomSchemaOption

 public function testCompareChangedColumns_ChangeCustomSchemaOption()
 {
     $column1 = new Column('charfield1', Type::getType('string'));
     $column2 = new Column('charfield1', Type::getType('string'));
     $column1->setCustomSchemaOption('foo', 'bar');
     $column2->setCustomSchemaOption('foo', 'bar');
     $column1->setCustomSchemaOption('foo1', 'bar1');
     $column2->setCustomSchemaOption('foo2', 'bar2');
     $c = new Comparator();
     $this->assertEquals(array('foo1', 'foo2'), $c->diffColumn($column1, $column2));
     $this->assertEquals(array(), $c->diffColumn($column1, $column1));
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:ComparatorTest.php

示例2: onSchemaColumnDefinition

 public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $args)
 {
     $tableColumn = array_change_key_case($args->getTableColumn(), CASE_LOWER);
     $table = $args->getTable();
     $info = null;
     if ('geometry' === $tableColumn['type']) {
         $info = $this->schemaManager->getGeometrySpatialColumnInfo($table, $tableColumn['field']);
     } elseif ('geography' === $tableColumn['type']) {
         $info = $this->schemaManager->getGeographySpatialColumnInfo($table, $tableColumn['field']);
     }
     if (!$info) {
         return;
     }
     $default = null;
     if (isset($tableColumn['default']) && 'NULL::geometry' !== $tableColumn['default'] && 'NULL::geography' !== $tableColumn['default']) {
         $default = $tableColumn['default'];
     }
     $options = array('notnull' => (bool) $tableColumn['isnotnull'], 'default' => $default, 'primary' => (bool) ($tableColumn['pri'] == 't'), 'comment' => isset($tableColumn['comment']) ? $tableColumn['comment'] : null);
     $column = new Column($tableColumn['field'], PostGISType::getType($tableColumn['type']), $options);
     $column->setCustomSchemaOption('geometry_type', $info['type'])->setCustomSchemaOption('srid', $info['srid']);
     $args->setColumn($column)->preventDefault();
 }
开发者ID:novikovsergey,项目名称:doctrine-postgis,代码行数:22,代码来源:DBALSchemaEventSubscriber.php

示例3: onSchemaColumnDefinition

 /**
  * @param \Doctrine\ORM\Tools\Event\SchemaColumnDefinitionEventArgs $args
  */
 public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $args)
 {
     $tableColumn = $args->getTableColumn();
     $table = $args->getTable();
     $conn = $args->getConnection();
     $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
     if ($tableColumn['type'] !== 'geometry') {
         return;
     }
     $sql = "SELECT COUNT(*) as index_exists\n                FROM pg_class, pg_index\n                WHERE oid IN (\n                    SELECT indexrelid\n                    FROM pg_index si, pg_class sc, pg_namespace sn\n                    WHERE sc.relname = ? AND sc.oid = si.indrelid AND sc.relnamespace = sn.oid\n                 ) AND pg_index.indexrelid = oid AND relname = ?";
     $stmt = $conn->prepare($sql);
     $stmt->execute(array($table, $this->generateIndexName($table, $tableColumn['field'])));
     $row = $stmt->fetch(\PDO::FETCH_ASSOC);
     $indexExists = $row['index_exists'] > 0;
     $sql = 'SELECT coord_dimension, srid, type FROM geometry_columns WHERE f_table_name = ? AND f_geometry_column = ?';
     $stmt = $conn->prepare($sql);
     $stmt->execute(array($table, $tableColumn['field']));
     $row = $stmt->fetch(\PDO::FETCH_ASSOC);
     $type = strtolower($row['type']);
     $options = array('length' => null, 'notnull' => (bool) $tableColumn['isnotnull'], 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null, 'primary' => (bool) ($tableColumn['pri'] == 't'), 'precision' => null, 'scale' => null, 'fixed' => null, 'unsigned' => false, 'autoincrement' => false, 'comment' => isset($tableColumn['comment']) ? $tableColumn['comment'] : null);
     $column = new Column($tableColumn['field'], Type::getType($type), $options);
     $column->setCustomSchemaOption('spatial_srid', (int) $row['srid'])->setCustomSchemaOption('spatial_dimension', (int) $row['coord_dimension'])->setCustomSchemaOption('spatial_index', (bool) $indexExists);
     $args->preventDefault()->setColumn($column);
 }
开发者ID:nvdnkpr,项目名称:doctrine-spatial-sandbox,代码行数:27,代码来源:PostgreSqlHandler.php

示例4: onSchemaColumnDefinition

 /**
  * @param \Doctrine\ORM\Tools\Event\SchemaColumnDefinitionEventArgs $args
  */
 public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $args)
 {
     $tableColumn = $args->getTableColumn();
     $table = $args->getTable();
     $conn = $args->getConnection();
     $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
     switch (strtolower($tableColumn['type'])) {
         case 'point':
         case 'linestring':
         case 'polygon':
         case 'multipoint':
         case 'multilinestring':
         case 'multipolygon':
         case 'geometrycollection':
             break;
         default:
             return;
     }
     $sql = "SHOW INDEX FROM " . $table . " WHERE Column_name = ?";
     $stmt = $conn->prepare($sql);
     $stmt->execute(array($this->generateIndexName($table, $tableColumn['field'])));
     $indexExists = (bool) $stmt->fetch(\PDO::FETCH_ASSOC);
     $options = array('length' => null, 'unsigned' => false, 'fixed' => null, 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null, 'notnull' => (bool) ($tableColumn['null'] != 'YES'), 'scale' => null, 'precision' => null, 'autoincrement' => false, 'comment' => isset($tableColumn['comment']) ? $tableColumn['comment'] : null);
     $column = new Column($tableColumn['field'], Type::getType($tableColumn['type']), $options);
     $column->setCustomSchemaOption('spatial_srid', 4326)->setCustomSchemaOption('spatial_dimension', 2)->setCustomSchemaOption('spatial_index', $indexExists);
     $args->preventDefault()->setColumn($column);
 }
开发者ID:nvdnkpr,项目名称:doctrine-spatial-sandbox,代码行数:30,代码来源:MySqlHandler.php


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