- Improved addIndex
[activemongo.git] / tests / Models.php
blob56b39588618c08bf04cccf09f6224040acff40be
1 <?php
3 class Dummy extends ActiveMongo
7 class Model1 extends ActiveMongo
9 public $a;
10 public $b;
12 static $validates_presence_of = array(
13 'a'
16 function before_create()
20 function setup()
22 $this->addIndex('b');
23 $this->addIndex(array('a' => -1));
28 class Model2 extends ActiveMongo
30 public $M1;
31 public $a;
33 static $validates_presence_of = array(
34 'M1',
37 function M1_filter($obj)
39 if (!$obj InstanceOf MongoID) {
40 if (isset($this->no_throw)) {
41 return FALSE;
42 } else {
43 throw new ActiveMongo_FilterException("Invalid M1 value");
48 function setup()
50 $this->addIndex(array('M1'));
53 function update_refs($m1)
55 /* reset just in case */
56 $this->reset();
57 $this->where('M1', $m1['_id']);
58 $this->Update(array('a' => $m1['a']));
63 class Model3 extends ActiveMongo
65 public $int;
66 public $str;
68 static $validates_presence_of = array(
69 'int'