Skip to content

Instantly share code, notes, and snippets.

@cameronjacobson
Last active December 15, 2015 08:29
Show Gist options
  • Save cameronjacobson/5230875 to your computer and use it in GitHub Desktop.
Save cameronjacobson/5230875 to your computer and use it in GitHub Desktop.
Intuitive way to interact with CouchDB documents
<?php
/**
* Phreezer project page:
* https://github.com/cameronjacobson/Phreezer
*/
class Vehicle
{
public function __construct(){}
}
require_once('vendor/autoload.php');
use Phreezer\Storage\CouchDB;
$couch = new CouchDB([
'database' => 'mydb'
]);
// create vehicle object and store it in CouchDB
$vehicle = new Vehicle();
$vehicle->make = 'Ford';
$vehicle->model = 'Mustang';
$uuid = $couch->store($vehicle);
// retrieve vehicle object from CouchDB
$vehicle = $couch->fetch($uuid);
var_dump($vehicle);
// delete vehicle object
$vehicle->_delete = true;
$couch->store($vehicle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment