You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,21 @@ $tsx->rollback();
127
127
$tsx->commit([Statement::create('MATCH (x) RETURN x LIMIT 100')]);
128
128
```
129
129
130
+
### Differentiating between parameter type
131
+
132
+
Cypher has lists and maps. This notion can be problematic as the standard php arrays encapsulate both. When you provide an empty array as a parameter, it will be impossible to determine if it is an empty list or map.
133
+
134
+
The `ParameterHelper` class is the ideal companion for this:
135
+
136
+
```php
137
+
use Laudis\Neo4j\ParameterHelper;
138
+
139
+
$client->run('MATCH (x) WHERE x.slug in $listOrMap RETURN x', ['listOrMap' => ParameterHelper::asList([])]); // will return an empty set
140
+
$client->run('MATCH (x) WHERE x.slug in $listOrMap RETURN x', ['listOrMap' => ParameterHelper::asMap([])]); // will error
141
+
$client->run('MATCH (x) WHERE x.slug in $listOrMap RETURN x', ['listOrMap' => []]); // will error
142
+
```
143
+
144
+
This helper can also be used to make intent explicit.
130
145
131
146
### Providing custom injections
132
147
@@ -163,9 +178,9 @@ Flexibility is maintained where possible by making all parameters iterables if t
0 commit comments