66use GuzzleHttp \Client ;
77use GuzzleHttp \Exception \GuzzleException ;
88use GuzzleHttp \Exception \RequestException ;
9+ use Neo4j \QueryAPI \Objects \ResultCounters ;
910use Neo4j \QueryAPI \Results \ResultRow ;
1011use Neo4j \QueryAPI \Results \ResultSet ;
1112use Neo4j \QueryAPI \Exception \Neo4jException ;
@@ -42,13 +43,14 @@ public static function login(string $address, string $username, string $password
4243 * @throws Neo4jException
4344 * @throws RequestExceptionInterface
4445 */
45- public function run (string $ cypher , array $ parameters , string $ database = 'neo4j ' ): ResultSet
46+ public function run (string $ cypher , array $ parameters = [] , string $ database = 'neo4j ' ): ResultSet
4647 {
4748 try {
4849 // Prepare the payload for the request
4950 $ payload = [
5051 'statement ' => $ cypher ,
5152 'parameters ' => empty ($ parameters ) ? new stdClass () : $ parameters ,
53+ 'includeCounters ' => true
5254 ];
5355
5456 // Execute the request to the Neo4j server
@@ -71,7 +73,22 @@ public function run(string $cypher, array $parameters, string $database = 'neo4j
7173 return new ResultRow ($ data );
7274 }, $ values );
7375
74- return new ResultSet ($ rows );
76+ return new ResultSet ($ rows , new ResultCounters (
77+ containsUpdates: $ data ['counters ' ]['containsUpdates ' ],
78+ nodesCreated: $ data ['counters ' ]['nodesCreated ' ],
79+ nodesDeleted: $ data ['counters ' ]['nodesDeleted ' ],
80+ propertiesSet: $ data ['counters ' ]['propertiesSet ' ],
81+ relationshipsCreated: $ data ['counters ' ]['relationshipsCreated ' ],
82+ relationshipsDeleted: $ data ['counters ' ]['relationshipsDeleted ' ],
83+ labelsAdded: $ data ['counters ' ]['labelsAdded ' ],
84+ labelsRemoved: $ data ['counters ' ]['labelsRemoved ' ],
85+ indexesAdded: $ data ['counters ' ]['indexesAdded ' ],
86+ indexesRemoved: $ data ['counters ' ]['indexesRemoved ' ],
87+ constraintsAdded: $ data ['counters ' ]['constraintsAdded ' ],
88+ constraintsRemoved: $ data ['counters ' ]['constraintsRemoved ' ],
89+ containsSystemUpdates: $ data ['counters ' ]['containsSystemUpdates ' ],
90+ systemUpdates: $ data ['counters ' ]['systemUpdates ' ]
91+ ));
7592 } catch (RequestExceptionInterface $ e ) {
7693 $ response = $ e ->getResponse ();
7794 if ($ response !== null ) {
0 commit comments