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

create documents with unique keys with php memcached

1 reply [Last post]
  • Login or register to post comments
Tue, 12/27/2011 - 16:45
martinsbalodis
Offline
Joined: 10/10/2011
Groups: None

In the documentation it is shown that you can create multiple documents with the same key and not override them like this:

<?php
// setup skipped
$cb->set('a', '{"name": "Simon"}');
$cb->set('a', '{"name": "Ben"}');
$cb->set('a', '{"name": "James"}');

After this I should create a view and get a list of all these persons. In the browser couchbase console I can see only "James". It seems that this document was written and overwritten three times. How can I create documents with unique CouchDB keys?

I am running ubuntu 10.10 64bit, php 5.3, PHP SDK: Ubuntu 9.04, 64-bit (10.x compatible, Debian compatible).

Top
  • Login or register to post comments
Thu, 12/29/2011 - 19:38
ingenthr
Offline
Joined: 03/16/2010
Groups:

Since you're overwriting the same key/_id multiple times [each invocation of the set() has the same 'a' for the key] you're replacing Simon and Ben with James. Things are behaving correctly. Instead, you should try

$cb->set('a', '{"name": "Simon"}');
$cb->set('b', '{"name": "Ben"}');
$cb->set('c', '{"name": "James"}');

That'll create three documents, all should be in the view.

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