Implement PHP Driver and Client by Maytch · Pull Request #384 · apache/age
Implemented AGTypeParse to parse results from PHP PostgreSQL fetch functions
Implemented AgeClient wrapper for PHP PostgreSQL Functions https://www.php.net/manual/en/ref.pgsql.php
$this->ageClient->query("
SELECT * FROM cypher('$graphName', $$
CREATE
(a:Part {part_num: '123'}),
(b:Part {part_num: '345'}),
(c:Part {part_num: '456'}),
(d:Part {part_num: '789'})
$$) as (a agtype);
");
$results = $this->ageClient->query("
SELECT * FROM cypher('$graphName', $$
MATCH
(a:Part)
RETURN a
$$) as (a agtype);
")->fetchAll();
And a Cypher-specific prepared statement method to remove PostgreSQL statement clutter and might prevent potential injections:
$this->ageClient->cypherQuery($graphName, 0, "
CREATE
(a:Person {name: \$p1}),
(b:Person {name: \$p2}),
(a)-[:KNOWS]->(b)
",[
'p1' => 'Steven',
'p2' => 'Mary'
]);
$results = $this->ageClient->cypherQuery($graphName, 3, "
MATCH
(a:Person {name: \$p1})-[r]-(b)
RETURN *
",[
'p1' => 'Steven'
])->fetchRow();