I want to write a GIS (geospatial data) extension for my Doctrine 2 project.
I know how to write simple custom functions and types. In order to accommodate the MySQL special storage format, I need to use some SQL function (GeomFromWKB() and AsBinary()) when retrieving/storing data.
I can't find a place where I tell Doctrine 2 this. As I see it, the convertToPHPValue() and convertToDatabaseValue() methods are not the right place.
If you want to call SQL function in doctrine2 you can do it be Expression Func but this will works only with DQL.
Here you have example that will tell you how to use DATE_DIFF function that is not included in doctrine.
$qb = $repository->createQueryBuilder('l');
$qb->expr()->lte(new Doctrine\ORM\Query\Expr\Func('DATE_DIFF',array('lo.start_date', 'CURRENT_DATE()')),'0');
What I found out so far: According to the IRC channel, convertToPHPValueSQL() and convertToDatabaseValueSQL() will be part of the next release, and will offer the functionality required. Once that is available, defining a CustomType is fairly straightforward.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With