Skip to content

Commit d226517

Browse files
committed
add array types integration doc
1 parent 2d347d0 commit d226517

File tree

1 file changed

+74
-7
lines changed

1 file changed

+74
-7
lines changed

docs/Types.md

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,77 @@
11
Available types
22
===============
33

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) |
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

Comments
 (0)