Permalink
Browse files

Merge pull request #4 from julienfastre/master

add documentation for new methods in Doctrine::Type
  • Loading branch information...
2 parents ed68431 + a645502 commit 3d20e9a5c414a64a0ae8496a23beb4e89245116a Guilherme Blanco committed Feb 17, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 en/reference/types.rst
View
@@ -132,6 +132,32 @@ Now we implement our ``Doctrine\DBAL\Types\Type`` instance:
}
}
+The job of Doctrine-DBAL is to transform your type into SQL declaration. You can modify the SQL declaration Doctrine will produce. At first, you must to enable this feature by overriding the canRequireSQLConversion method:
+
+::
+
+ <?php
+ public function canRequireSQLConversion()
+ {
+ return true;
+ }
+
+Then you can override the methods convertToPhpValueSQL and convertToDatabaseValueSQL :
+
+::
+
+ <?php
+ public function convertToPHPValueSQL($sqlExpr, $platform)
+ {
+ return 'MyMoneyFunction(\''.$sqlExpr.') ';
+ }
+
+ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
+ {
+ return 'MyFunction('.$sqlExpr.')';
+ }
+
+
Now we have to register this type with the Doctrine Type system and
hook it into the database platform:

0 comments on commit 3d20e9a

Please sign in to comment.