Reputation: 15
I just started using Riak (for a college project) and we got a CentOS machine with Riak 1.4.2 on it.
I made a bucket called "testbucket" and in it key,value pair "helloworld", "Hello World!" using curl. Then I tried fetching the data using curl and browser, and everything was fine, I got "Hello World!" back as intended.
The problem was that I need to make a web project using PHP and I'm stuck with the following:
<?php
require_once('riak-php-client-master/src/Basho/Riak/Riak.php');
require_once('riak-php-client-master/src/Basho/Riak/Bucket.php');
require_once('riak-php-client-master/src/Basho/Riak/Exception.php');
require_once('riak-php-client-master/src/Basho/Riak/Link.php');
require_once('riak-php-client-master/src/Basho/Riak/MapReduce.php');
require_once('riak-php-client-master/src/Basho/Riak/Object.php');
require_once('riak-php-client-master/src/Basho/Riak/StringIO.php');
require_once('riak-php-client-master/src/Basho/Riak/Utils.php');
require_once('riak-php-client-master/src/Basho/Riak/Link/Phase.php');
require_once('riak-php-client-master/src/Basho/Riak/MapReduce/Phase.php');
$connection = new Basho\Riak\Riak('192.168.56.12', 10018);
$bucket = new Basho\Riak\Bucket($connection, 'testbucket');
$object = $bucket->get('helloworld');
var_dump($object);
?>
var_dump prints the following:
object(Basho\Riak\Object)[3]
protected 'meta' =>
array (size=0)
empty
protected 'indexes' =>
array (size=0)
empty
protected 'autoIndexes' =>
array (size=0)
empty
public 'client' =>
object(Basho\Riak\Riak)[1]
public 'host' => string '192.168.56.12' (length=13)
public 'port' => int 10018
public 'prefix' => string 'riak' (length=4)
public 'mapred_prefix' => string 'mapred' (length=6)
public 'indexPrefix' => string 'buckets' (length=7)
public 'clientid' => string 'php_us1pa7' (length=10)
public 'r' => int 2
public 'w' => int 2
public 'dw' => int 2
public 'bucket' =>
object(Basho\Riak\Bucket)[2]
public 'client' =>
object(Basho\Riak\Riak)[1]
public 'host' => string '192.168.56.12' (length=13)
public 'port' => int 10018
public 'prefix' => string 'riak' (length=4)
public 'mapred_prefix' => string 'mapred' (length=6)
public 'indexPrefix' => string 'buckets' (length=7)
public 'clientid' => string 'php_us1pa7' (length=10)
public 'r' => int 2
public 'w' => int 2
public 'dw' => int 2
public 'name' => string 'testbucket' (length=10)
public 'r' => null
public 'w' => null
public 'dw' => null
public 'key' => string 'helloworld' (length=10)
public 'jsonize' => boolean true
public 'headers' =>
array (size=10)
'http_code' => int 200
'x-riak-vclock' => string 'a85hYGBgzGDKBVIcKlYHQkK6OW9mMCUy5bEyBGgwn+PLAgA=' (length=48)
'vary' => string 'Accept-Encoding' (length=15)
'server' => string 'MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)' (length=57)
'link' => string '</riak/testbucket>; rel="up"' (length=28)
'last-modified' => string 'Mon, 15 Dec 2014 09:39:28 GMT' (length=29)
'etag' => string '"y0akdKQCeEWM2HBgOp0tK"' (length=23)
'date' => string 'Mon, 15 Dec 2014 13:56:54 GMT' (length=29)
'content-type' => string 'text/html' (length=9)
'content-length' => string '38' (length=2)
public 'links' =>
array (size=0)
empty
public 'siblings' => null
public 'exists' => boolean true
public 'data' => null
Of course, trying to do $object->getData() results in Exception. I'm completely baffled as the data clearly exists (checked with both curl and through browser) and yet I can't seem to access it this way. It seems weird especially as the line "'content-length' => string '38' (length=2)" says that obviously there should be some data in the body.
Upvotes: 0
Views: 115