Beispiel #1
0
function result()
{
    $options = array('database' => Configuration::kDatabaseName);
    $db = new CouchDB($options);
    return $db->view('categories/all');
}
<?php

require $_SERVER['DOCUMENT_ROOT'] . '/application/system/Environment.php';
$key = filter_var($_GET['key'], FILTER_UNSAFE_RAW);
if (preg_match('/[\\w\\d]{32}/', $key)) {
    $options = array('database' => Configuration::kDatabaseName);
    $db = new CouchDB($options);
    $query_options = array('key' => $key);
    $result = $db->view('users/accountAuthorization', $query_options);
    if (count($result) > 0) {
        $authtoken = $result[0]['value']['key'];
        if ($authtoken == $key) {
            $user = new User();
            $db_user = $db->document($result[0]['value']['user']);
            $user->initWithArray($db_user);
            $user->isValid = true;
            $user->save();
            $db->delete($result[0]['value']['_id'], $result[0]['value']['_rev']);
        }
    }
    header('location: /');
}
Beispiel #3
0
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 *    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 *    PURPOSE. See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 *    Author: Adam Venturella - aventurella@gmail.com
 *
 *    @package Sample 
 *    @author Adam Venturella <*****@*****.**>
 *    @copyright Copyright (C) 2009 Adam Venturella
 *    @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
 *
 **/
/**
 * Sample
 */
require 'couchdb/CouchDB.php';
$newdb = 'newdb';
$options = array('database' => $newdb);
$db = new CouchDB($options);
$query_options = array('key' => '*****@*****.**');
$view = $db->view('users/all');
$viewWithQueryOptions = $db->view('users/all', $query_options);
// get the first result:
echo '<p>', print_r($viewWithQueryOptions[0], true), '</p>';
// loop over all of the results
foreach ($view as $row) {
    echo '<pre>', print_r($row, true), '</pre>';
}
 public function testReplicationViewDefaultCount()
 {
     $replicated = new CouchDB(array('database' => CouchDBTestConstants::kAltDatabaseName));
     $result = $replicated->view('records/default_count');
     $this->assertEquals(2, $result[0]['value']);
 }