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

PHP view slash problem

1 reply [Last post]
  • Login or register to post comments
Sun, 01/20/2013 - 23:55
hhtu
Offline
Joined: 12/27/2012
Groups: None

Hi

When I have a problem when I use php view function

Here is the problem, if I want to select something like startkey=['apple', null]&endkey=['apple', "\u0fff"]

I can easily type this in couchbase web filter and sure it gives me what I want (I want select all results).

But, if I write this in php code

$cb->view("task", "apple", array('startkey'=>['apple', null], 'endkey'=>['apple', '\u0fff']));

It returned nothing!!

then I tried this

echo urldecode($cb->viewGenQuery("task", "task_apple", array('startkey'=>['apple', null], 'endkey'=>['apple', '\u0fff'])));

result:

/_design/task/_view/task_apple?startkey=["apple",null]&endkey=["apple","\\u0fff"]

turns out it adds an extra slash there, how do I solve this problem? thanks....

Top
  • Login or register to post comments
Tue, 01/22/2013 - 09:59
mnunberg
Offline
Joined: 04/25/2012
Groups: None

Since the input array itself becomes serialized to JSON, as a consequence any character which is "special" to JSON is escaped as well. I am guessing the only way you can get the effect of \u0fff is to place a literal one inside the string. Hopefully PHP's json encoding will do the trick.

You can also disable smart serialization of parameters (via OPT_PASSTHROUGH) - which means that instead of passing an array to 'startkey' it would need to be an already-serialized JSON array

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