Industrial
Industrial

Reputation: 42758

Creating views with PHP for couchDB

I have started to try out noSQL databases now and are currently testing out couchDB. Seems like a good solution, but I really get some headache when I follow available examples on how to create views (queries) to select documents from a database and sort them.

Everything I can find is regarding JavaScript and it would be great to take part of some examples for PHP since that is the language we will use.

So, how do I create views using PHP for couchDB?

Upvotes: 2

Views: 1299

Answers (4)

cemerick
cemerick

Reputation: 5916

Javascript is privileged as a CouchDB view server only because that's what's bundled with CouchDB. There are view server implementations for many other languages/runtimes, including PHP.

Upvotes: 3

Aaron McAdam
Aaron McAdam

Reputation: 706

Try PHPillow man

Here's a very short introduction to it: http://www.catswhocode.com/blog/getting-started-with-couchdb-tutorial-a-beginners-guide

If you check out the SVN of PHPillow, there's more information in the 'docs' folder

Upvotes: 0

ryeguy
ryeguy

Reputation: 66851

I think you need to understand Javascript's stance in CouchDB. Javascript isn't a target language like PHP, Ruby, etc. Javascript is more equivalent to SQL here. The javascript is server-side and CouchDB itself actually executes it. This is what you use to do map/reduce and build views and such.

Upvotes: 1

Pascal MARTIN
Pascal MARTIN

Reputation: 401002

As far as I know, the equivalent of the SQL language that would be used for a relationnal database is, for CouchDB, Javascript.

So, if you want to create some "query", or "view", you have to do it in that language : it's the one that's understood by CouchDb.


PHP and CouchDb are totally independant : the only thing is that :

  • PHP can send requests to CouchDb
  • and get results

But what happens on the CouchDb side is independant of your PHP script -- and there is no PHP on the CouchDb side.


The only way to filter results using PHP would be to :

  • Request more data from CouchDb than you need
  • And throw away, from PHP, what's not needed

But, obviously, that would not be an efficient solution...

Upvotes: 5

Related Questions