getGeometrySpatialColumnInfo() public method

public getGeometrySpatialColumnInfo ( $table, $column )
コード例 #1
0
 public function testGetGeometrySpatialColumnInfo()
 {
     $schemaManager = new SchemaManager($this->_getConnection());
     $this->assertNull($schemaManager->getGeometrySpatialColumnInfo('foo.points', 'text'));
     $expected = array('type' => 'GEOMETRY', 'srid' => 0);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'geometry'));
     $expected = array('type' => 'POINT', 'srid' => 0);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point'));
     $expected = array('type' => 'POINT', 'srid' => 3785);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point_2d'));
     $expected = array('type' => 'POINTZ', 'srid' => 3785);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point_3dz'));
     $expected = array('type' => 'POINTM', 'srid' => 3785);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point_3dm'));
     $expected = array('type' => 'POINTZM', 'srid' => 3785);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point_4d'));
     $expected = array('type' => 'POINT', 'srid' => 3785);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point_2d_nullable'));
     $expected = array('type' => 'POINT', 'srid' => 0);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('points', 'point_2d_nosrid'));
 }
コード例 #2
0
 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();
 }
コード例 #3
0
 public function testGetGeometrySpatialColumnInfoWithReservedWords()
 {
     $schemaManager = new SchemaManager($this->_getConnection());
     $expected = array('type' => 'GEOMETRY', 'srid' => 0);
     $this->assertEquals($expected, $schemaManager->getGeometrySpatialColumnInfo('"user"', '"user"'));
 }