PHP code example of doctrine / couchdb-odm
1. Go to this page and download the library: Download doctrine/couchdb-odm library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
doctrine / couchdb-odm example snippets
/**
* @Document
*/
class Article
{
/** @Id */
private $id;
/**
* @Field(type="string")
*/
private $topic;
/**
* @Field(type="string")
*/
private $text;
/**
* @ReferenceOne(targetDocument="User")
*/
private $author;
// a bunch of setters and getters
}
$article = new Article();
$article->setTopic("Doctrine CouchDB");
$article->setText("Documentation");
$article->setAuthor(new Author("beberlei"));
// creating the document
$dm->persist($article);
$dm->flush();
$article = $dm->find("Article", 1234);
$article->setText("Documentation, and more documentation!");
// update the document
$dm->flush();
// removing the document
$dm->remove($article);
$dm->flush();