Created
July 6, 2011 13:42
-
-
Save janl/1067238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cb = new Couchbase; | |
$cb->addServer("localhost", 11211); // BC compat | |
$view = $cb->getView("ddocname", "viewname"); // returns Couchbase_View | |
$result = $view->getResult(); // returns Couchbase_ViewResult | |
foreach($result->rows AS $row) { | |
echo $row->value; | |
} | |
$result = $view->getResult(array("descending" => true)); | |
foreach($result->rows AS $row) { | |
echo $row->value; | |
} | |
$result = $view->getResultRange($start, $end); // returns Couchbase_ViewResult | |
foreach($result->rows AS $row) { | |
echo $row->value; | |
} | |
$result = $view->getResultRange($start, $end, array("descending" => true)); // returns Couchbase_ViewResult | |
foreach($result->rows AS $row) { | |
echo $row->value; | |
} | |
$resultPages = $view->getResultPageinator(); // returns Couchbase_ViewResultPaginator implements Iterator | |
$resultPages->setRowsPerPage(10); | |
while($page = $resultPages->next()) { // returns Couchbase_ViewResult | |
foreach($page->rows AS $row) { | |
echo $row->value | |
} | |
} | |
$resultPages = $view->getResultPageinator(); | |
$resultPages->setRowsPerPage(int $rowsPerPage); | |
$resultPages->setPageKey(string $pageKey); // jump to specific page | |
$resultPages->setOptions(array $options); // regular query options | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment