通过php执行多个合并neo4j查询
到目前为止,我一直在使用neo4j查询,但我想知道它是否会使neo4j内存不足,因为我没有在任何地方提交(我猜它是自动提交的)。但是,只有担心neo4j会因为我的查询而关闭或减慢时,查询才能正常工作。我真的很感谢你的帮助 sample.php通过php执行多个合并neo4j查询,neo4j,Neo4j,到目前为止,我一直在使用neo4j查询,但我想知道它是否会使neo4j内存不足,因为我没有在任何地方提交(我猜它是自动提交的)。但是,只有担心neo4j会因为我的查询而关闭或减慢时,查询才能正常工作。我真的很感谢你的帮助 sample.php <?php if (!empty($array)) { if( get_magic_quotes_gpc() ) { $array = stripslashes( $array ); } $newstr = json_
<?php
if (!empty($array)) {
if( get_magic_quotes_gpc() ) {
$array = stripslashes( $array );
}
$newstr = json_decode( preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $array), true );
if(!empty($newstr)){
$j=0;
foreach($newstr as $item) { //foreach element in $arr
$category_id = $item['category_id']; //etc
$category_name = $item['category_name'];
$category = $item['category'];
$data2 .=' MERGE (u'.$j.':Category {name:"'.$category_name.'",id:"'.$category_id.'",category:"'.$category
.'"}) ';
$j=$j+1;
}
$data2 = array("query" =>$data2);
$data_string = json_encode($data2);
$ch = curl_init('http://localhost:7474/db/data/cypher');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
}else{
echo "null";
}
}
?>
您正在使用,它会在成功查询结束时自动提交。因此,不必担心丢失数据
但是,遗留端点现在被弃用,所以您应该考虑转换到.
另外,作为建议,您可以更改此代码段:
' MERGE (u'.$j.':Category {name:"'
致:
您的查询从不使用uxxx
标识符,因此无需首先定义它们。因此,如何将现有的cypher http端点更改为事务端点。我应该改一下吗:从一个帖子到另一个帖子???
' MERGE (:Category {name:"'