CouchDB ODM
Doctrine CouchDB是PHP和CouchDB文档之间的映射器。 它使用元数据映射模式将文档映射到普通的旧php对象,不需要任何类型的ActiveRecord模式或基类。
元数据映射可以通过注释、xml、yaml或php完成。 使用注释映射到CouchDB的示例PHP对象如下所示:
/**
* @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
}
此文档的简单工作流程如下所示:
<?php
$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();
您可以使用每个git checkout的沙箱/文件夹中提供的沙箱,或者阅读文档 http://docs.doctrine-project.org/projects/doctrine-couchdb/en/latest/

