0

Could you please tell me which command line can help me to reinitialize a neo4j query, to explain more, I have a query which gives all users nodes and the second query gives folders nodes, unfortunately, the second query remember the result of the first query.

EDIT 0

Here follows a concatenation of additional information that OP posted as answers. To the one who is able, please merge the edits and remove this comment.

EDIT 1

            <td>
            <select name=user>
            <?php
            $result1 = $client->sendCypherQuery("MATCH (n:$label1) return n")->getResult();
            $i=0;
            foreach ($result1->getNodes() as $nu){

                $n[$i]=$nu->getproperty('lastname');
                $i++;
            }
                while ($j<$i)
                {
                echo "<option value='$n[$j]'> $n[$j] </option>";
                $j=$j+1;
                }
                echo "</select>";

            ?>
            </td>
        </tr>
        <tr>
            <td>Nom dossier :</td>
            <td>
            <select name=folder>
            <?php
            $result2 = $client->sendCypherQuery("MATCH (n:$label2) return n")->getResult();
            $i=0;
            foreach ($result2->getNodes() as $nd){

                $d[$i]=$nd->getProperty('name');
                $i++;
            }
            $j=0;
                while ($j<$i)
                {
                echo "<option value='$d[$j]'> $d[$j] </option>";
                $j=$j+1;
                }
                echo "</select>";
            ?>
            </td>
        </tr>

EDIT 2

I have 2 users and 2 folders. $result1 should return the users and $result2 should return the folders. when I look for the size of folders I get 4 and not 2 so the query remembers always the result of the first query.

EDIT 3

var_dump($result1), I get:

object(Neoxygen\NeoClient\Formatter\Result)  protected 'nodes' => 
array (size=2)
  7 => 
    object(Neoxygen\NeoClient\Formatter\Node)[796]
      protected 'id' => string '7' (length=1)
      protected 'labels' => 
        array (size=1)
          ...
      protected 'properties' => 
        array (size=6)
          ...
      protected 'inboundRelationships' => 
        array (size=0)
          ...
      protected 'outboundRelationships' => 
        array (size=0)
          ...
  9 => 
    object(Neoxygen\NeoClient\Formatter\Node)[797]
      protected 'id' => string '9' (length=1)
      protected 'labels' => 
        array (size=1)
          ...
      protected 'properties' => 
        array (size=6)
          ...
      protected 'inboundRelationships' => 
        array (size=0)
          ...
      protected 'outboundRelationships' => 
        array (size=0)
          ...   protected 'relationships' => 
array (size=0)
  empty   protected 'errors' => null 
  protected 'identifiers' => 
array (size=1)
  'n' => 
    array (size=2)
      0 => 
        object(Neoxygen\NeoClient\Formatter\Node)[796]
          ...
      1 => 
        object(Neoxygen\NeoClient\Formatter\Node)[797]
          ...

EDIT 4

and var_dump($result2):

object(Neoxygen\NeoClient\Formatter\Result)  protected 'nodes' => 
array (size=4)
  7 => 
    object(Neoxygen\NeoClient\Formatter\Node)[799]
      protected 'id' => string '7' (length=1)
      protected 'labels' => 
        array (size=1)
          ...
      protected 'properties' => 
        array (size=6)
          ...
      protected 'inboundRelationships' => 
        array (size=0)
          ...
      protected 'outboundRelationships' => 
        array (size=0)
          ...
  9 => 
    object(Neoxygen\NeoClient\Formatter\Node)[800]
      protected 'id' => string '9' (length=1)
      protected 'labels' => 
        array (size=1)
          ...
      protected 'properties' => 
        array (size=6)
          ...
      protected 'inboundRelationships' => 
        array (size=0)
          ...
      protected 'outboundRelationships' => 
        array (size=0)
          ...
  8 => 
    object(Neoxygen\NeoClient\Formatter\Node)[787]
      protected 'id' => string '8' (length=1)
      protected 'labels' => 
        array (size=1)
          ...
      protected 'properties' => 
        array (size=2)
          ...
      protected 'inboundRelationships' => 
        array (size=0)
          ...
      protected 'outboundRelationships' => 
        array (size=0)
          ...
  10 => 
    object(Neoxygen\NeoClient\Formatter\Node)[788]
      protected 'id' => string '10' (length=2)
      protected 'labels' => 
        array (size=1)
          ...
      protected 'properties' => 
        array (size=2)
          ...
      protected 'inboundRelationships' => 
        array (size=0)
          ...
      protected 'outboundRelationships' => 
        array (size=0)
          ...

EDIT 5

<?php    include 'connection.php'; 
$j=0;

$l=0;

$label1="user";

$label2="folder1";

?>
<br><br><br>    
<h3>Ajouter relation</h3>    
<form action='php/addlink.php' method=post>
    <table>
        <tr>
            <td>Nom utilisateur:</td>
            <td>
            <select name=user>
            <?php
            $result1 = $client->sendCypherQuery("MATCH (n:$label1) return n")->getResult();

            $i=0;
            foreach ($result1->getNodes() as $nu){

                $n[$i]=$nu->getproperty('lastname');
                $i++;
            }
                while ($j<$i)
                {
                echo "<option value='$n[$j]'> $n[$j] </option>";
                $j=$j+1;
                }
                echo "</select>";

            ?>
            </td>
        </tr>
        <tr>
            <td>Nom dossier :</td>
            <td>
            <select name=folder>
            <?php
            $result2 = $client->sendCypherQuery("MATCH (n:$label2) return n")->getResult();

            $i=0;
            foreach ($result2->getNodes() as $nd){

                $d[$i]=$nd->getid();
                $i++;
            }
            $j=0;
                while ($j<$i)
                {
                echo "<option value='$d[$j]'> $d[$j] </option>";
                $j=$j+1;
                }
                echo "</select>";
            ?>
jjaderberg
  • 9,844
  • 34
  • 34
Amina el
  • 75
  • 8
  • Please post the queries. What are their results? What do you expect? – FrobberOfBits Aug 25 '15 at 15:01
  • the problem is: $d[$j] return the result of the first query and also the second query – Amina el Aug 25 '15 at 15:08
  • 2
    please post the queries as part of the question, not in tiny comments. it is almost unreadable especially on mobile – Christophe Willemsen Aug 25 '15 at 15:45
  • Amina these queries only differ by `$label1` and `$label2`. What are those values? If they're the same, the query returning the same thing makes sense. – FrobberOfBits Aug 25 '15 at 16:18
  • $label1=user $label2=folder the problem is : the second query has always in memory the result of the first query. So when I want to get the size, I get the addition of the both – Amina el Aug 25 '15 at 16:40
  • 2
    @Aminael, if you want someone to help you with your problem, you will want to take the time to learn how StackOverflow works. In particular, you will want to **edit your question** to add further information. The answers you have provided are not answers, and now it is very confusing for someone trying to read your question and help you. Hopefully you can still get your problem resolved, but for a sporting chance in the future, you will want to invest that time to learn to do StackOverflow. – jjaderberg Aug 25 '15 at 21:24

1 Answers1

1

This is really strange, I have created an integration test which proves that results are not duplicated in subsequent queries :

https://github.com/neoxygen/neo4j-neoclient/blob/master/tests/Neoxygen/NeoClient/Tests/Issues/IssueSOResultDuplicationTest.php

So I would look on different positions :

  1. Make sure there are only 2 folder nodes
  2. Check that all your variables are reinitialized
  3. The labels provided in the query

NB: You can edit your original question instead of creating multiple replies.

I have test your code, just replacing the labels with those in my db, and I only get 2 folders :

enter image description here

So I would check the db content, can you try in your browser to make the second query manually.

Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36