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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序