neo4j 在php中运行多行密码查询时出错

c0vxltue  于 2022-11-05  发布在  PHP
关注(0)|答案(1)|浏览(217)

我得到这个错误,而运行此查询密码从luadis php驱动程序单行查询运行,但多行查询密码不运行

$hosturl =  self::$config['hosturl'];
$result = $client->run("
            UNWIND range(0,4) as level
            CALL apoc.cypher.doIt('
            MATCH (c:Category { pagesFetched: false, level: $level })
            CALL apoc.load.json('$hosturl/w/api.php?format=json&action=query&list=categorymembers&cmtype=page&cmtitle=Category:' + apoc.text.urlencode(c.catName) + '&cmprop=ids|title&cmlimit=500')
            YIELD value as results
            UNWIND results.query.categorymembers AS page
            MERGE (p:Page {pageId: page.pageid})
            ON CREATE SET p.pageTitle = page.title, p.pageUrl = '$hosturl/wiki/' + apoc.text.urlencode(replace(page.title, ' ', '_'))
            WITH p,c
            MERGE (p)-[:IN_CATEGORY]->(c)
            WITH DISTINCT c
            SET c.pagesFetched = true', { level: level }) yield value
            return value");

我得到这个错误:

[Sat Feb 19 00:27:39 2022] PHP Fatal error:  Uncaught Bolt\error\MessageException: Invalid input 'h': expected whitespace, '.', node labels or rel types, '[', '^', '*', '/', '%', '+', '-', "=~", IN, STARTS, ENDS, CONTAINS, IS, '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, ',' or ')' (line 5,
column 25 (offset: 141))
"                       CALL apoc.load.json('https://en.wikipedia.org/w/api.php?format=json&action=query&list=categorymembers&cmtype=page&cmtitle=Category:' + apoc.text.urlencode(c.catName) + '&cmprop=ids|title&cmlimit=500')"
                         ^ (Neo.ClientError.Statement.SyntaxError) in C:\xampp\htdocs\Graph\vendor\stefanak-michal\bolt\src\protocol\V3.php:82
Stack trace:

# 0 C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Bolt\BoltUnmanagedTransaction.php(131): Bolt\protocol\V3->run()

# 1 C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Bolt\Session.php(87): Laudis\Neo4j\Bolt\BoltUnmanagedTransaction->runStatements()

# 2 C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Client.php(77): Laudis\Neo4j\Bolt\Session->runStatements in C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Exception\Neo4jException.php on line 50

[Sat Feb 19 00:27:39 2022] [::1]:1194 [500]: GET /querycypher.php - Uncaught Bolt\error\MessageException: Invalid input 'h': expected whitespace, '.', node labels or rel types, '[', '^', '*', '/', '%', '+', '-', "=~", IN, STARTS, ENDS, CONTAINS, IS, '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, O
R, ',' or ')' (line 5, column 25 (offset: 141))
"                       CALL apoc.load.json('https://en.wikipedia.org/w/api.php?format=json&action=query&list=categorymembers&cmtype=page&cmtitle=Category:' + apoc.text.urlencode(c.catName) + '&cmprop=ids|title&cmlimit=500')"
                         ^ (Neo.ClientError.Statement.SyntaxError) in C:\xampp\htdocs\Graph\vendor\stefanak-michal\bolt\src\protocol\V3.php:82
Stack trace:

# 0 C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Bolt\BoltUnmanagedTransaction.php(131): Bolt\protocol\V3->run()

# 1 C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Bolt\Session.php(87): Laudis\Neo4j\Bolt\BoltUnmanagedTransaction->runStatements()

# 2 C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Client.php(77): Laudis\Neo4j\Bolt\Session->runStatements in C:\xampp\htdocs\Graph\vendor\laudis\neo4j-php-client\src\Exception\Neo4jException.php on line 50

[Sat Feb 19 00:27:39 2022] [::1]:1194 Closing

请告诉我怎么解决这个问题请帮帮我

qv7cva1a

qv7cva1a1#

我不是很理解apoc调用的用法,你可以直接内联查询,如下所示:

$result = $client->run(<<<'CYPHER'
            UNWIND range(0,4) as level
            MATCH (c:Category { pagesFetched: false, level: level })
            CALL apoc.load.json($hostUrl + '/w/api.php?format=json&action=query&list=categorymembers&cmtype=page&cmtitle=Category:' + apoc.text.urlencode(c.catName) + '&cmprop=ids|title&cmlimit=500')
            YIELD value as results
            UNWIND results.query.categorymembers AS page
            MERGE (p:Page {pageId: page.pageid})
            ON CREATE SET p.pageTitle = page.title, p.pageUrl = '$hosturl/wiki/' + apoc.text.urlencode(replace(page.title, ' ', '_'))
            WITH p,c
            MERGE (p)-[:IN_CATEGORY]->(c)
            WITH DISTINCT c
            SET c.pagesFetched = true
            CYPHER, ['hostUrl' => $hostUrl]);

相关问题