Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 60 lines (44 sloc) 1.48 kB
25eb848 @beberlei Update README with hackathon discussions
beberlei authored
1 # CouchDB ODM
942ae85 @beberlei Initial commit of CouchDB ODM
beberlei authored
2
1cd2978 @beberlei Update README
beberlei authored
3 Doctrine CouchDB is a mapper between PHP and CouchDB documents. It uses a metadata mapping
4 pattern to map the documents to plain old php objects, no ActiveRecord pattern or base class
5 of any kind is necessary.
6505065 @beberlei Add a simple usage example to README with links to sandbox and docume…
beberlei authored
6
7 Metadata mapping can be done through annotations, xml, yaml or php. A sample PHP object
8 that is mapped to CouchDB with annotations looks like this:
9
10 /**
11 * @Document
12 */
13 class Article
14 {
15 /** @Id */
16 private $id;
17
18 /**
19 * @Field(type="string")
20 */
21 private $topic;
22
23 /**
24 * @Field(type="string")
25 */
26 private $text;
27
28 /**
29 * @ReferenceOne(targetDocument="User")
30 */
31 private $author;
32
33 // a bunch of setters and getters
34 }
35
36 A simple workflow with this document looks like:
37
38 $article = new Article();
39 $article->setTopic("Doctrine CouchDB");
40 $article->setText("Documentation");
41 $article->setAuthor(new Author("beberlei"));
42
43 // creating the document
44 $dm->persist($article);
45 $dm->flush();
46
47 $article = $dm->find("Article", 1234);
48 $article->setText("Documentation, and more documentation!");
49
50 // update the document
51 $dm->flush();
52
53 // removing the document
54 $dm->remove($article);
55 $dm->flush();
56
57 You can play around with the sandbox shipped in the sandbox/ folder of every git checkout
58 or read the documentation at http://www.doctrine-project.org/docs/couchdb_odm/1.0/en/
59
Something went wrong with that request. Please try again.