{"id":10006015,"date":"2022-07-25T16:49:31","date_gmt":"2022-07-25T08:49:31","guid":{"rendered":"https:\/\/ityet.com\/?p=10006015"},"modified":"2022-07-25T16:49:31","modified_gmt":"2022-07-25T08:49:31","slug":"%e5%9b%be%e6%95%b0%e6%8d%ae%e5%ba%93neo4j%e7%9a%84php%e5%ba%93","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006015","title":{"rendered":"\u56fe\u6570\u636e\u5e93neo4j\u7684PHP\u5e93"},"content":{"rendered":"<p>git \u9879\u76ee\u5730\u5740 <a href=\"https:\/\/link.segmentfault.com\/?enc=%2BdB2UGJV597gxbzsD0Ottw%3D%3D.EF2QWpCuUyZUIaCkNPTP%2Foy2G6%2B1yB2tM9eE%2Fm0FgDXXmJNxUTy80cVbLfCLvg6S\" rel=\"nofollow\">church\/neo4j<\/a><\/p>\n<h2>\u4ecb\u7ecd<\/h2>\n<blockquote><p>\u57fa\u4e8ePHP\u7684neo4j\u5e93\uff0c\u6e90\u6587\u6863\u94fe\u63a5\u5730\u5740 <a href=\"https:\/\/link.segmentfault.com\/?enc=pu3aqMaiODwSatMPGzWSTA%3D%3D.JALbFGruXXpgwfJkZ%2FFSnfdoZ%2B8TNuKOnO4fEGh6WQEeV6XkWd4J81jwWseD9W%2BF1dxv527vX4zkHQckDlznWQ%3D%3D\" rel=\"nofollow\">neo4j http api<\/a><\/p><\/blockquote>\n<h2>\u5b89\u88c5\u73af\u5883\u9700\u6c42<\/h2>\n<ul>\n<li>PHP &gt;= 7.4<\/li>\n<\/ul>\n<h2>\u5b89\u88c5<\/h2>\n<pre><code class=\"shell\">composer require church\/neo4j<\/code><\/pre>\n<h2>\u7528\u6cd5<\/h2>\n<h3>\u521d\u59cb\u5316<\/h3>\n<pre><code class=\"php\">$app = new \/Church\/Neo4j\/Application(&quot;http:\/\/127.0.0.1:7474&quot;, &quot;neo4j&quot;, &quot;neo4j&quot;);\n$app-&gt;discovery();\n<\/code><\/pre>\n<h3>\u67e5\u8be2\u8bed\u53e5<\/h3>\n<pre><code class=\"php\">$statement = (new \/Church\/Neo4j\/Statement('CREATE (n $props) RETURN n)'))-&gt;params([\n    'props' =&gt; [\n        'name' =&gt; 'test'\n    ]   \n]);<\/code><\/pre>\n<h3>\u5f00\u542f\u4e8b\u52a1<\/h3>\n<pre><code class=\"php\">$statements = \/Church\/Neo4j\/StatementRepository::add($statement);\n$transaction = $app-&gt;transaction($statements);\n$transaction-&gt;begin();<\/code><\/pre>\n<h3>\u63d0\u4ea4\u4e8b\u52a1<\/h3>\n<pre><code class=\"php\">$result = $transaction-&gt;commit();\n\nif ($result-&gt;getRawResponse()-&gt;getStatusCode() == 200) {\n    print_r($result-&gt;getData());\n}\n<\/code><\/pre>\n<h3>\u5ef6\u957f\u4e8b\u52a1\u6709\u6548\u671f<\/h3>\n<blockquote><p>default expiry time is 60 seconds.<\/p><\/blockquote>\n<pre><code class=\"php\">$transaction-&gt;keepAlive(); <\/code><\/pre>\n<h3>\u56de\u6eda<\/h3>\n<pre><code class=\"php\">$transaction-&gt;rollback();<\/code><\/pre>\n<h3>\u5f00\u542f\u548c\u63d0\u4ea4\u4e8b\u52a1<\/h3>\n<pre><code class=\"php\">$result = $transaction-&gt;beginAndCommit();\nprint_r($result);<\/code><\/pre>\n<h2>\u5355\u5143\u6d4b\u8bd5<\/h2>\n<pre><code class=\"shell\">composer install\n.\/vendor\/bin\/phpunit<\/code><\/pre>\n<h2>\u534f\u8bae<\/h2>\n<blockquote><p>MIT<\/p><\/blockquote>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042219418\">https:\/\/segmentfault.com\/a\/1190000042219418<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>git \u9879\u76ee\u5730\u5740 church\/neo4j \u4ecb\u7ecd \u57fa\u4e8ePHP\u7684neo4j\u5e93\uff0c\u6e90\u6587\u6863\u94fe\u63a5\u5730\u5740 neo4j htt [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006015","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006015"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006015\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}