Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

(PHP) Undefined Index from existing keys in getMulti result

2 replies [Last post]
  • Login or register to post comments
Wed, 03/21/2012 - 15:45
nwelch
Offline
Joined: 03/21/2012
Groups: None

Hi, we are testing Couchbase and the 1.0.1 (current) PHP SDK on our dev servers and are noticing some strange behavior from the getMulti function: keys which exist and are visible when print_r'ing the response give an undefined index error when we try to access them.

Here's our code:

$couchbase = new Couchbase(COUCHBASE_HOST . ':' . COUCHBASE_PORT);
$queryKeys = array('testKey', 'testKey1');
// Delete all the keys and then give them some values
foreach ($queryKeys as $currKey) {
    $couchbase->delete($currKey);
    $couchbase->set($currKey, 'testVal ' . $currKey);
}
 
$multiResult = $GLOBALS['membase']->getMulti($queryKeys);
print_r($multiResult); // Shows correct result array
print "\n\n";
 
// Go through the results
foreach ($multiResult as $resultKey => $resultValue) {
    print "result key: $resultKey ; result value: $resultValue \n";
    var_dump($resultKey);
    print "multiResult[$resultKey]: ";
    var_dump(@$multiResult[$resultKey]); // Undefined index error without @
 
    print "\n";
}
 
print "\n\n------\n\n";
 
// Go through the keys that we queried couchbase with
foreach ($queryKeys as $currKey) {
    print "query key: $currKey \n";
    var_dump($currKey);
    var_dump(@$multiResult[$currKey]); // Undefined index error without @
}

Here's the output: http://pastebin.com/MASx6v5K

So the problem is that the array that getMulti returns is somehow not accessible by either its own keys (when iterating with a foreach) or the keys used to query couchbase. This always worked fine with libmemcached. Any ideas on what we're doing wrong or what the problem could be?

Thanks

Server details:
Couchbase server: Version: 1.8.0 enterprise edition (build-55)
PHP: 5.3.5

libcouchbase-devel version 1.0.2
libcouchbase1 version 1.0.2

Top
  • Login or register to post comments
Fri, 03/23/2012 - 13:48
ingenthr
Offline
Joined: 03/16/2010
Groups:

Off the top of my head, I don't see anything incorrect there. Thanks for all of the good info, this should help us track it down quickly.

I've filed http://www.couchbase.com/issues/browse/PCBC-59 and we'll try to look into it. You may want to add yourself to the watch list there to see updates.

Top
  • Login or register to post comments
Fri, 03/23/2012 - 15:19
nwelch
Offline
Joined: 03/21/2012
Groups: None

Thanks for the reply and for filing the big, ingenthr. Let me know if you need any other info from us.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker