Skip to content

Commit 17a2734

Browse files
committed
reorder statement running options
1 parent fd5439a commit 17a2734

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

README.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,47 @@ echo $result; // echos 'z'
7575
## Decide how to send your Cypher queries
7676

7777
You can control the driver using three different approaches:
78-
- *Transaction functions* (recommended and portable)
7978
- *Auto committed queries* (easiest and most intuitive)
79+
- *Transaction functions* (most portable)
8080
- *Unmanaged transactions* (for the highest degree of control)
8181

82+
83+
### Auto committed queries
84+
85+
Auto committed queries are the most straightforward and most intuitive but have many drawbacks when running complex business logic or within a high availability environment.
86+
87+
#### Run a simple cypher query
88+
89+
```php
90+
$client->run(
91+
'MERGE (user {email: $email})', //The query is a required parameter
92+
['email' => '[email protected]'], //Requests can be optionally added
93+
'backup' //The default connection can be overridden
94+
);
95+
```
96+
97+
#### Run a statement object:
98+
99+
```php
100+
use Laudis\Neo4j\Databags\Statement;
101+
102+
$statement = new Statement('MERGE (user {email: $email})', ['email' => '[email protected]']);
103+
$client->runStatement($statement, 'default');
104+
```
105+
106+
#### Running multiple queries at once
107+
108+
The `runStatements` method will run all the statements at once. This method is an essential tool to reduce the number of database calls, especially when using the HTTP protocol.
109+
110+
```php
111+
use Laudis\Neo4j\Databags\Statement;
112+
113+
$results = $client->runStatements([
114+
Statement::create('MATCH (x) RETURN x LIMIT 100'),
115+
Statement::create('MERGE (x:Person {email: $email})', ['email' => '[email protected]'])
116+
]);
117+
```
118+
82119
### Transaction functions
83120

84121
Transaction functions are the **de facto** standard when using the driver. It is the most portable as it is resistant to a lot of the pitfalls when first developing with high availability solutions such as [Neo4j aura](https://neo4j.com/blog/neo4j-aura-enterprise-ga-release/) or a [cluster](https://neo4j.com/docs/operations-manual/current/clustering/).
@@ -121,42 +158,6 @@ $client->writeTransaction(static function (TransactionInterface $tsx) use ($id)
121158
$externalCounter->incrementNodesCreated();
122159
```
123160

124-
### Auto committed queries
125-
126-
Auto committed queries are the most straightforward and most intuitive but have many drawbacks when running complex business logic or within a high availability environment.
127-
128-
#### Run a simple cypher query
129-
130-
```php
131-
$client->run(
132-
'MERGE (user {email: $email})', //The query is a required parameter
133-
['email' => '[email protected]'], //Requests can be optionally added
134-
'backup' //The default connection can be overridden
135-
);
136-
```
137-
138-
#### Run a statement object:
139-
140-
```php
141-
use Laudis\Neo4j\Databags\Statement;
142-
143-
$statement = new Statement('MERGE (user {email: $email})', ['email' => '[email protected]']);
144-
$client->runStatement($statement, 'default');
145-
```
146-
147-
#### Running multiple queries at once
148-
149-
The `runStatements` method will run all the statements at once. This method is an essential tool to reduce the number of database calls, especially when using the HTTP protocol.
150-
151-
```php
152-
use Laudis\Neo4j\Databags\Statement;
153-
154-
$results = $client->runStatements([
155-
Statement::create('MATCH (x) RETURN x LIMIT 100'),
156-
Statement::create('MERGE (x:Person {email: $email})', ['email' => '[email protected]'])
157-
]);
158-
```
159-
160161
### Unmanaged transactions
161162

162163
If you need lower-level access to the drivers' capabilities, then you want unmanaged transactions. They allow for completely controllable commits and rollbacks.

0 commit comments

Comments
 (0)