首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何重新初始化Neo4j查询?

如何重新初始化Neo4j查询?
EN

Stack Overflow用户
提问于 2015-08-25 14:44:22
回答 1查看 100关注 0票数 0

请告诉我哪个命令行可以帮助我重新初始化一个neo4j查询,为了解释更多,我有一个给所有用户节点的查询,第二个查询给出了节点,不幸的是,第二个查询记住了第一个查询的结果。

编辑0

下面是OP作为答案发布的附加信息的连接。对于有能力的人,请合并编辑并删除此注释。

编辑1

代码语言:javascript
复制
            <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

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

编辑3

var_dump($result1),我明白:

代码语言:javascript
复制
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)

代码语言:javascript
复制
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

代码语言:javascript
复制
<?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>";
            ?>
EN

回答 1

Stack Overflow用户

发布于 2015-08-25 17:18:53

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

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

所以我会看不同的位置:

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

注:你可以编辑你的原始问题,而不是创建多个答复。

我已经测试了您的代码,只需将标签替换为我的db中的标签,我只得到两个文件夹:

所以我会检查db内容,您能在浏览器中手动进行第二个查询吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32207128

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档