skip to Main Content

change from Everyman Client to Laudis Client for PHP access to AURA DB (Neo4j).

Code:

$outerQuery = "MATCH (n) return n.name AS name";
$outerResult = $client->run($outerQuery);

foreach ($outerResult as $detailOut) {

    $innerQuery = 'MATCH (n) WHERE n.name = "'.detailOut['name'].'" return n';
    $innerResult = $client->run($innerQuery);

    foreach ($innerResult as $detailIn) {
    // do something
    } 
}

$client is constructed like this

// embedding Neo4J PHP DB driver                                                              
use LaudisNeo4jAuthenticationAuthenticate;
use LaudisNeo4jClientBuilder;

// establish a client-object for database access
$client = ClientBuilder::create()
  ->withDriver(
    'example',
    $_ENV['db_url'],
    Authenticate::basic($_ENV['db_username'], $_ENV['db_password'])
)
->build();

The outer query gets a valid result but the outer loop breaks whenever the inner db statement is executed first – be it with depending parameters or without. You can do code before the statement, thats not an issue, but the run-statement kills the outer loop. If I comment out the run-statement in the inner loop, the loops are running correctly and showing the expected results. The statements have been tested in the Neo4j Browser and are ok, but even with simple statements like these examples it breaks the outer loop.

My only guess is that I cannot use these statements with the LAUDIS client as I am used to with the Everyman Client.

Anyone has an idea what I need to change or what other code I need to use to have an inner loop statement that depends on fields of the result of an outer loop?

Thank you

2

Answers


  1. Chosen as BEST ANSWER

    The version 2.7 of the client was causing the problem, gladly version 2.8 now has a fix so the Problem is solved: upgrade to latest version.


  2. Does it maybe break because you’re missing one quotation mark?

     # before:
        $innerQuery = 'MATCH (n) WHERE n.name = "'.detailOut['name'].'" return n";
    '# after:
        $innerQuery = 'MATCH (n) WHERE n.name = "'.detailOut['name'].'" return n"';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search