0

您能否告诉我哪个命令行可以帮助我重新初始化 neo4j 查询,解释更多,我有一个查询提供所有用户节点,第二个查询提供文件夹节点,不幸的是,第二个查询记住第一个查询的结果.

编辑 0

以下是 OP 作为答案发布的附加信息的串联。对于有能力的人,请合并编辑并删除此评论。

编辑 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>

编辑 2

我有 2 个用户和 2 个文件夹。 $result1应该返回用户并$result2返回文件夹。当我查找文件夹的大小时,我得到 4 而不是 2,因此查询始终记住第一个查询的结果。

编辑 3

var_dump($result1),我得到:

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]
          ...

编辑 4

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)
          ...

编辑 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>";
            ?>
4

1 回答 1

1

这真的很奇怪,我创建了一个集成测试,证明结果在后续查询中不会重复:

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

所以我会看不同的立场:

  1. 确保只有 2 个文件夹节点
  2. 检查所有变量是否已重新初始化
  3. 查询中提供的标签

注意:您可以编辑原始问题,而不是创建多个回复。

我已经测试了你的代码,只是用我的数据库中的标签替换了标签,我只得到了 2 个文件夹:

在此处输入图像描述

所以我会检查数据库内容,您可以尝试在浏览器中手动进行第二个查询。

于 2015-08-25T17:18:53.623 回答