dready92 / PHP-on-Couch

Data Access Library to access a CouchDB server with PHP.
http://dready.byethost31.com/index.php/display/view/192
GNU Lesser General Public License v3.0
246 stars 102 forks source link

Your example with creating a view in couch-client_view.md does not work this way... #17

Closed SMut closed 13 years ago

SMut commented 13 years ago

You try to define a map this way: $view_fn="function(doc) { emit(doc.timestamp,null); }"; //<- no map key here! $design_doc->views = array ( 'by_date',$view_fn); //<- so, this won't work! because the map key is missing, so $view_fn must be an array!

I use this definition and it works as expected: $view_fn=array( 'map' => 'function(doc) { emit(doc.timestamp,null); }'); $design_doc->views = array ( 'by_date',$view_fn);

Great piece of work, thank you very much for githubbing without your work I'd be lost...

dready92 commented 13 years ago

Hello Smut,

thanks for taking the time to give me some feedback on PoC. I don't know the version of the documenation you're seeing, but the last one (I pushed it the third of december) seems to be good.

There is no difference between doing :

$view_fn=array( 'map' => 'function(doc) { emit(doc.timestamp,null); }'); 
$design_doc->views = array ( 'by_date',$view_fn);

(your way), and doing :

$view_fn="function(doc) { emit(doc.timestamp,null); }";
$design_doc->views = array ( 'by_date'=> array ('map' => $view_fn ) );

(the doc way). The reason I wrote the documentation like this is to isolate the Javascript code ( $view_fn ) from the PHP stuff. Perhaps I should add more comments to better explain the "Creating a view" chapter.. ?

Regards,

Mickael

SMut commented 13 years ago

Hi Mickael,

in the documentation it would be a huge increase of usability for couchDB if you add a section for 'views for SQL junkies' like in O'reilleys couchDB book.

I read the book very often online, but it's got no examples for your great PHP tool. So I always take a peek there and use your great piece of software to find a way to get those examples working.

What I'd really need is a book about couchDB, PHP on the server side including AJAX-requests using jQuery. It seems to me, when I get my 'handballplaner'-stuff running the way I want it, I should write a book about this matter :-)

Everything's fine and thanks a lot for your work and help in the past, for a newbie laying RESTless on the couch :-P