1

I have the following code using PHP & GraphAware:

$stack = $client->stack();
$stack->push('  MATCH (student:Student{id:123})
        MATCH (spring:Term{name:"Spring2017"})
        MATCH (class:Class{name:"Cypher101"})
        MERGE (student)-[:ENROLLED_IN]->(class)-[:FOR_TERM]->(spring)');
$results = $client->runStack($stack);

$res = $client->run('MATCH (n) RETURN count(n)');
print_r($res->records());

I have copied the example code found here: https://neo4j.com/developer/kb/understanding-how-merge-works/ and for some reason the print_r() returns the following:

Array
(
    [0] => GraphAware\Bolt\Record\RecordView Object
        (
            [keys:protected] => Array
                (
                    [0] => count(n)
                )

            [values:protected] => Array
                (
                    [0] => 0
                )

            [keyToIndexMap:GraphAware\Bolt\Record\RecordView:private] => Array
                (
                    [count(n)] => 0
                )

        )

)

If I run a CREATE command the query works fine but for some reason the code above won't. Can someone advise me what I'm doing wrong?

Rajendra Kadam
  • 4,004
  • 1
  • 10
  • 24
Antony
  • 3,875
  • 30
  • 32

1 Answers1

2

Your query seems correct.

Check if these nodes exist in the Neo4j Database.

  • If these are not present in the database first create these nodes and then run the query.
  • You can also replace MATCH with MERGE, in that case, you don't
    have to create these nodes separately.

NOTE: Multiple MERGE in a single query is not recommended, so try to use the first solution (creating the nodes separately).

Rajendra Kadam
  • 4,004
  • 1
  • 10
  • 24