6
6
use GuzzleHttp \Client ;
7
7
use GuzzleHttp \Exception \GuzzleException ;
8
8
use GuzzleHttp \Exception \RequestException ;
9
+ use Neo4j \QueryAPI \Objects \ResultCounters ;
9
10
use Neo4j \QueryAPI \Results \ResultRow ;
10
11
use Neo4j \QueryAPI \Results \ResultSet ;
11
12
use Neo4j \QueryAPI \Exception \Neo4jException ;
@@ -42,13 +43,14 @@ public static function login(string $address, string $username, string $password
42
43
* @throws Neo4jException
43
44
* @throws RequestExceptionInterface
44
45
*/
45
- public function run (string $ cypher , array $ parameters , string $ database = 'neo4j ' ): ResultSet
46
+ public function run (string $ cypher , array $ parameters = [] , string $ database = 'neo4j ' ): ResultSet
46
47
{
47
48
try {
48
49
// Prepare the payload for the request
49
50
$ payload = [
50
51
'statement ' => $ cypher ,
51
52
'parameters ' => empty ($ parameters ) ? new stdClass () : $ parameters ,
53
+ 'includeCounters ' => true
52
54
];
53
55
54
56
// Execute the request to the Neo4j server
@@ -71,7 +73,22 @@ public function run(string $cypher, array $parameters, string $database = 'neo4j
71
73
return new ResultRow ($ data );
72
74
}, $ values );
73
75
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
+ ));
75
92
} catch (RequestExceptionInterface $ e ) {
76
93
$ response = $ e ->getResponse ();
77
94
if ($ response !== null ) {
0 commit comments