Skip to content

Commit

Permalink
Add missing steps for adding own types based on official Doctrine doc…
Browse files Browse the repository at this point in the history
…umentation (martin-georgiev#47)
  • Loading branch information
bednic authored and martin-georgiev committed Apr 16, 2019
1 parent 1fa732c commit d5c6b84
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions docs/INTEGRATING-WITH-DOCTRINE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Integration with Symfony
## Integration with Doctrine


*Register the DBAL types you plan to use*
Expand All @@ -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
Expand All @@ -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);
```
```

*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[]');
...

```

0 comments on commit d5c6b84

Please sign in to comment.