dongshi8425 2015-05-21 05:38
浏览 110

在Windows上为Couchbase设置PHP SDK?

Can anyone please help me out with step by step setting up of PHP SDK for Couchbase on Windows and running a simple PHP file using Couchbase. I tried running the following PHP program and have already followed the instructions given in this blog (http://trondn.blogspot.no/2013/04/couchbase-php-xampp-and-windows.html)

PHP file:

<?php
// Connect to Couchbase Server
$cluster = new CouchbaseCluster('http://127.0.0.1:8091');
$bucket = $cluster->openBucket('beer-sample');
// Retrieve a document
$result = $bucket->get('aass_brewery-juleol');
$doc = $result->value;
echo $doc->name . ', ABV: ' . $doc->abv . "
";
// Store a document
$doc->comment = 'Random beer from Norway';
$result = $bucket->replace('aass_brewery-juleol', $doc);
var_dump($result);
?>

I keep getting the error: Fatal error: Uncaught exception 'CouchbaseException' with message 'The key does not exist on the server' in [CouchbaseNative]/CouchbaseBucket.class.php:196 Stack trace: #0 [CouchbaseNative]/CouchbaseBucket.class.php(196): _CouchbaseBucket->get('aass_brewery-ju...', Array) #1 C:\xampp\htdocs\hello-couchbase.php(9): CouchbaseBucket->get('aass_brewery-ju...') #2 {main} thrown in [CouchbaseNative]/CouchbaseBucket.class.php on line 196

I have couchbase installed and a sample bucket - 'beer-sample' installed

  • 写回答

1条回答 默认 最新

  • doujugu1722 2015-12-16 19:45
    关注

    Don't use accounts with admin permissions to perform data transactions. Either pass NULL as the username or name of the bucket. Here's a sample code.

    $cb = new Couchbase("127.0.0.1:8091", "", "", "beer-sample");
    $cb->set("foo", "bar");
    var_dump("foo");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog