2 require "../../ActiveMongo.php";
6 ActiveMongo
::connect("activemongo_blog");
8 /* This should be done just once */
9 ActiveMongo
::install();
11 /* Create a new author
12 * The property country is not defined
13 * as an AuthorModel property, but it will
16 $author = new AuthorModel
;
17 $author->username
= "crodas";
18 $author->name
= "Cesar Rodas";
19 $author->country
= "PY";
22 /* Add one blog post */
23 $post = new PostModel
;
24 $post->uri
= "/hello-world";
25 $post->title
= "Hello World";
26 $post->author
= $author;
29 /* Add another post */
30 $post = new PostModel
;
31 $post->uri
= "/yet-another-post";
32 $post->title
= "Yet another post";
33 $post->author
= $author;
35 $post->add_comment("testing", "root@foo.com", "testing comment");
38 /* add another comment */
39 $post->add_comment("testing", "root@foo.com", "cool post");
42 /* Clean up the current the resultset */
43 /* same as $post = null; $post = new Post Model */
44 /* but more efficient */
46 $post->author
= $author->getID();
47 foreach ($post->find() as $bp) {
48 var_dump("Author: ".$bp->author_name
);
51 $author->name
= "cesar d. rodas";
54 var_dump("Author profile has been updated");
57 * List our blog posts in the correct order
58 * (descending by Timestamp).
60 foreach ($post->listing_page() as $bp) {
61 var_dump(array("Author" => $bp->author_name
, "Title"=>$bp->title
));
64 /* delete collections */