File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ require __DIR__ . '/../vendor/autoload.php ' ;
3
+
4
+ use GuzzleHttp \Client ;
5
+
6
+ $ neo4jUrl = 'https://6f72daa1.databases.neo4j.io/db/neo4j/query/v2 ' ;
7
+ $ username = 'neo4j ' ;
8
+ $ password = '9lWmptqBgxBOz8NVcTJjgs3cHPyYmsy63ui6Spmw1d0 ' ;
9
+
10
+ $ client = new Client ();
11
+
12
+ $ query = "PROFILE MATCH (n:Person) RETURN n " ;
13
+
14
+ $ response = $ client ->post ($ neo4jUrl , [
15
+ 'auth ' => [$ username , $ password ],
16
+ 'json ' => [
17
+ 'statement ' => $ query
18
+ ]
19
+ ]);
20
+
21
+ $ body = $ response ->getBody ();
22
+ $ data = json_decode ($ body , true );
23
+
24
+ $ output = [
25
+ "data " => [
26
+ "fields " => [],
27
+ "values " => []
28
+ ],
29
+ "profiledQueryPlan " => [],
30
+ "bookmarks " => $ data ['bookmarks ' ] ?? []
31
+ ];
32
+
33
+ if (isset ($ data ['result ' ]['columns ' ]) && isset ($ data ['result ' ]['rows ' ])) {
34
+ $ output ["data " ]["fields " ] = $ data ['result ' ]['columns ' ];
35
+ foreach ($ data ['result ' ]['rows ' ] as $ row ) {
36
+ $ output ["data " ]["values " ][] = $ row ;
37
+ }
38
+ }
39
+
40
+ if (isset ($ data ['profiledQueryPlan ' ])) {
41
+ $ output ["profiledQueryPlan " ] = $ data ['profiledQueryPlan ' ];
42
+ }
43
+
44
+ echo json_encode ($ output , JSON_PRETTY_PRINT );
You can’t perform that action at this time.
0 commit comments