Skip to content

Instantly share code, notes, and snippets.

@khepin
Created April 26, 2012 03:18
Show Gist options
  • Save khepin/2495430 to your computer and use it in GitHub Desktop.
Save khepin/2495430 to your computer and use it in GitHub Desktop.
<?php
namespace Powwow\NewdbBundle\Types;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* My custom datatype.
*/
class GeoType extends Type
{
const GEOTYPE = 'geotype'; // modify to match your type name
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return null;
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return null;
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
$dbval = 'SRID=4326;POINT(%s)';
$value = sprintf($dbval, $value);
return $value;
}
public function getName()
{
return self::GEOTYPE; // modify to match your constant name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment