Source of file DBGeometry.php
Size: 1,007 Bytes - Last Modified: 2021-12-23T10:37:40+00:00
/var/www/docs.ssmods.com/process/src/src/ORM/FieldType/DBGeometry.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | <?php namespace Smindel\GIS\ORM\FieldType; use SilverStripe\ORM\DB; use Smindel\GIS\GIS; class DBGeometry extends DBGeography { protected $srid; public function __construct($name = null, $srid = null, $options = []) { $this->srid = $srid; parent::__construct($name, $options); } /** * Add the field to the underlying database. */ public function requireField() { DB::require_field( $this->tableName, $this->name, [ 'type'=>'geometry', 'parts' => [ 'srid' => $this->srid, ] ] ); } public function compositeDatabaseFields() { return ['' => 'Geometry']; } public function prepValueForDB($value) { $value = GIS::create($value); if ($value->isNull()) { return null; } return ['ST_GeomFromText(?, ?)' => [$value->wkt, $value->srid]]; } } |