Skip to content

Conversation

@Maytch
Copy link

@Maytch Maytch commented Dec 13, 2022

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

AgeClient includes basic DIY query method:

$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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant