-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
48 lines (36 loc) · 1.04 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require_once('vendor/autoload.php');
class TestDocument extends Moa\DomainObject
{
public function properties()
{
return array(
'myInt' => new Moa\Types\IntegerField(array('required' => true)),
'myString' => new Moa\Types\StringField(),
'myArray' => new Moa\Types\ArrayField(),
'myEmbeddedArray' => new Moa\Types\ArrayField(array('type' => new Moa\Types\EmbeddedDocumentField(array('type' => 'TestDocument')))),
'myOwnSelf' => new Moa\Types\EmbeddedDocumentField(array('type'=>'TestDocument')),
);
}
}
$conn = new Mongo();
Moa::setup($conn->moademo);
TestDocument::remove();
$doc = new TestDocument(array(
'myInt' => 100
));
$doc->save();
$doc->myEmbeddedArray = array(
new TestDocument(array(
'myInt' => '101',
)),
new TestDocument(array(
'myInt' => '102',
'myString' => 'Item 2'
))
);
$doc->myOwnSelf = new TestDocument(array(
'myInt' => 2200
));;
$doc->save();
var_dump(iterator_to_array(TestDocument::find()));