CrEOF\Spatial\DBAL\Platform\AbstractPlatform::convertToDatabaseValue PHP Method

convertToDatabaseValue() public method

public convertToDatabaseValue ( CrEOF\Spatial\DBAL\Types\AbstractSpatialType $type, CrEOF\Spatial\PHP\Types\Geometry\GeometryInterface $value ) : string
$type CrEOF\Spatial\DBAL\Types\AbstractSpatialType
$value CrEOF\Spatial\PHP\Types\Geometry\GeometryInterface
return string
    public function convertToDatabaseValue(AbstractSpatialType $type, GeometryInterface $value)
    {
        return sprintf('%s(%s)', strtoupper($value->getType()), $value);
    }

Usage Example

 /**
  * @param AbstractGeometryType $type
  * @param GeometryInterface    $value
  *
  * @return string
  */
 public function convertToDatabaseValue(AbstractGeometryType $type, GeometryInterface $value)
 {
     $sridSQL = null;
     if ($type instanceof GeographyType && null === $value->getSrid()) {
         $value->setSrid(self::DEFAULT_SRID);
     }
     if (($srid = $value->getSrid()) !== null || $type instanceof GeographyType) {
         $sridSQL = sprintf('SRID=%d;', $srid);
     }
     return sprintf('%s%s', $sridSQL, parent::convertToDatabaseValue($type, $value));
 }