3 require "../../lib/ActiveMongo.php";
5 require "Services.php";
7 ActiveMongo
::connect("test");
12 /* Create an user for our 'aggregator' */
14 $user->username
= "crodas";
15 $user->password
= "crodas";
18 /* Now we are going to query for the services for
19 * the new user, it will return an empty
20 * dataset, but we're going to create a 'dynamic' reference
21 * to the 'query'. When this reference is deference
22 * then same 'query' is going to be asked to the database.
24 $service = new Service
;
25 $service->where('user', $user->getID())->doQuery();
28 $user->services
= $service->getReference(TRUE);
32 /* Create one service, note that Service::user is $user->getID() */
34 $twt->user
= $user->getID();
35 $twt->rss
= "http://twitter.com/statuses/user_timeline/crodas.rss";
38 /* Create another service */
40 $blg->user
= $user->getID();
41 $blg->rss
= "http://crodas.org/feed/rss";
44 /* Create another service */
46 $blg1->user
= $user->getID();
47 $blg1->rss
= "http://crodas.org/feed/rss";
50 /* Delete current objects */
51 unset($user, $blg, $blg1, $twt);
53 /* Output the document that is going to be sent to MongoDB */
57 foreach ($users->where('username', 'crodas') as $user) {
58 /* Load all references */
59 $user->doDeferencing();
61 /* Modify the first service */
62 $user->services
[0]->title
= 'English Blog';
64 /* You need to save the referenced document */
66 $user->services
[0]->save();
68 /* Modify the current user */
69 $user->foobar
= 'cesar';