无法通过php在apachephoenix中插入记录

6pp0gazn  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(252)

我正在努力选择 UPSERT apache phoenix中的值 PHP 班级。我可以 select 使用 php curl 查询安装在端口上的服务器 8765 ,就像我在例子中分享的。类似地,我尝试插入数据 (UPSERT) 在Phoenix城使用php curl。它给我的答复,但数据不插入。

PHP

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://localhost:8765/");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array();
// For Select.
//$headers[] = 'request: {"request":"prepareAndExecute","connectionId":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa","sql":"select * from BLOG.POST"}';

// For Upsert.
$headers[] = 'request: {"request":"prepareAndExecute","connectionId":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa","sql":"UPSERT INTO BLOG.POST (POST_ID,TITLE,CONTENT) values (\'aa11111\',\'Test Title\',\'this is test post content\')"}';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);

输出:

{"response":"Service$ExecuteResponse","results":[{"response":"resultSet","connectionId":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa","statementId":1164383384,"ownStatement":false,"signature":null,"firstFrame":null,"updateCount":1}]}

有人能告诉我我的方法有什么问题吗?或者通过php类连接ApachePhoenix的任何其他方法。

9nvpjoqh

9nvpjoqh1#

您好,您只需要在您的hbase配置文件中执行以下操作。
phoenix.connection.autocommit=true到hbase-site.xml

相关问题