|
| 1 | +Available types |
| 2 | +=============== |
| 3 | + |
| 4 | +| PostgreSQL type | Register as | Implementation | |
| 5 | +|-----------------|-------------|-----------------------------------------------------------------------------------------| |
| 6 | +| _bool | bool[] | [Pfilsx\PostgreSQLDoctrine\DBAL\Type\BooleanArray](../src/DBAL/Type/BooleanArray.php) | |
| 7 | +| _int2 | smallint[] | [Pfilsx\PostgreSQLDoctrine\DBAL\Type\SmallIntArray](../src/DBAL/Type/SmallIntArray.php) | |
| 8 | +| _int4 | integer[] | [Pfilsx\PostgreSQLDoctrine\DBAL\Type\IntegerArray](../src/DBAL/Type/IntegerArray.php) | |
| 9 | +| _int8 | bigint[] | [Pfilsx\PostgreSQLDoctrine\DBAL\Type\BigIntArray](../src/DBAL/Type/BigIntArray.php) | |
| 10 | +| _text | text[] | [Pfilsx\PostgreSQLDoctrine\DBAL\Type\TextArray](../src/DBAL/Type/TextArray.php) | |
| 11 | + |
| 12 | +Integration with Doctrine |
| 13 | +========================= |
| 14 | + |
| 15 | +```php |
| 16 | +<?php |
| 17 | + |
| 18 | +use Doctrine\DBAL\Types\Type; |
| 19 | + |
| 20 | +Type::addType('bool[]', 'Pfilsx\PostgreSQLDoctrine\DBAL\Type\BooleanArray'); |
| 21 | +Type::addType('smallint[]', 'Pfilsx\PostgreSQLDoctrine\DBAL\Type\SmallIntArray'); |
| 22 | +Type::addType('integer[]', 'Pfilsx\PostgreSQLDoctrine\DBAL\Type\IntegerArray'); |
| 23 | +Type::addType('bigint[]', 'Pfilsx\PostgreSQLDoctrine\DBAL\Type\BigIntArray'); |
| 24 | +Type::addType('text[]', 'Pfilsx\PostgreSQLDoctrine\DBAL\Type\TextArray'); |
| 25 | + |
| 26 | +// ... |
| 27 | + |
| 28 | +$platform = $em->getConnection()->getDatabasePlatform(); |
| 29 | +$platform->registerDoctrineTypeMapping('bool[]','bool[]'); |
| 30 | +$platform->registerDoctrineTypeMapping('_bool','bool[]'); |
| 31 | +$platform->registerDoctrineTypeMapping('integer[]','integer[]'); |
| 32 | +$platform->registerDoctrineTypeMapping('_int4','integer[]'); |
| 33 | +$platform->registerDoctrineTypeMapping('bigint[]','bigint[]'); |
| 34 | +$platform->registerDoctrineTypeMapping('_int8','bigint[]'); |
| 35 | +$platform->registerDoctrineTypeMapping('text[]','text[]'); |
| 36 | +$platform->registerDoctrineTypeMapping('_text','text[]'); |
| 37 | +``` |
| 38 | + |
| 39 | +Integration with Symfony |
| 40 | +========================= |
| 41 | +```yaml |
| 42 | +# config/packages/doctrine.yaml |
| 43 | +doctrine: |
| 44 | + dbal: |
| 45 | + types: |
| 46 | + bool[]: Pfilsx\PostgreSQLDoctrine\DBAL\Type\BooleanArray |
| 47 | + smallint[]: Pfilsx\PostgreSQLDoctrine\DBAL\Type\SmallIntArray |
| 48 | + integer[]: Pfilsx\PostgreSQLDoctrine\DBAL\Type\IntegerArray |
| 49 | + bigint[]: Pfilsx\PostgreSQLDoctrine\DBAL\Type\BigIntArray |
| 50 | + text[]: Pfilsx\PostgreSQLDoctrine\DBAL\Type\TextArray |
| 51 | + |
| 52 | + mapping_types: |
| 53 | + bool[]: bool[] |
| 54 | + _bool: bool[] |
| 55 | + smallint[]: smallint[] |
| 56 | + _int2: smallint[] |
| 57 | + integer[]: integer[] |
| 58 | + _int4: integer[] |
| 59 | + bigint[]: bigint[] |
| 60 | + _int8: bigint[] |
| 61 | + text[]: text[] |
| 62 | + _text: text[] |
| 63 | + # or |
| 64 | + connections: |
| 65 | + connection_name: |
| 66 | + mapping_types: |
| 67 | + bool[]: bool[] |
| 68 | + _bool: bool[] |
| 69 | + smallint[]: smallint[] |
| 70 | + _int2: smallint[] |
| 71 | + integer[]: integer[] |
| 72 | + _int4: integer[] |
| 73 | + bigint[]: bigint[] |
| 74 | + _int8: bigint[] |
| 75 | + text[]: text[] |
| 76 | + _text: text[] |
| 77 | +``` |
0 commit comments