From d5c6b8486c26aa6c1caf79b5e285db58a777c5c6 Mon Sep 17 00:00:00 2001 From: Tomas Benedikt Date: Tue, 16 Apr 2019 11:32:38 +0200 Subject: [PATCH] Add missing steps for adding own types based on official Doctrine documentation (#47) --- docs/INTEGRATING-WITH-DOCTRINE.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/INTEGRATING-WITH-DOCTRINE.md b/docs/INTEGRATING-WITH-DOCTRINE.md index 5a5336fe..b840b137 100644 --- a/docs/INTEGRATING-WITH-DOCTRINE.md +++ b/docs/INTEGRATING-WITH-DOCTRINE.md @@ -1,4 +1,4 @@ -## Integration with Symfony +## Integration with Doctrine *Register the DBAL types you plan to use* @@ -21,6 +21,7 @@ Type::addType('text[]', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\TextArray"); *Register the functions you'll use in your DQL queries* + Full set of the available types can be found [here](AVAILABLE-FUNCTIONS-AND-OPERATORS.md). ```php @@ -33,7 +34,21 @@ $configuration = new Configuration(); $configuration->addCustomStringFunction('TO_TSQUERY', MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\ToTsquery::class); $configuration->addCustomStringFunction('TO_TSVECTOR', MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\ToTsvector::class); $configuration->addCustomStringFunction('TSMATCH', MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Tsmatch::class); - ... + $em = EntityManager::create($dbParams, $configuration); -``` \ No newline at end of file +``` + +*Then you need to register type mappings like below, based on [documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/custom-mapping-types.html)* + +```php +$platform = $em->getConnection()->getDatabasePlatform(); +$platform->registerDoctrineTypeMapping('integer[]','integer[]'); +$platform->registerDoctrineTypeMapping('_int4','integer[]'); +$platform->registerDoctrineTypeMapping('bigint[]','bigint[]'); +$platform->registerDoctrineTypeMapping('_int8','bigint[]'); +$platform->registerDoctrineTypeMapping('text[]','text[]'); +$platform->registerDoctrineTypeMapping('_text','text[]'); +... + +```