public function prepareData() 
    {
	    $cats = array('cat1', 'cat2', 'cat3');
	    $now = time();
        for ($i = 0; $i < 10; $i++) {
		    $age = $now - rand(0,10000);
            $x = new RelX();
	        $x->name = "x $i";
		    $x->category = $cats[rand(0, 2)];
		    $x->set('created_at', strftime("%Y-%m-%d %H:%M:%S", $age));
	        $x->save();
        
	        for ($j = 0; $j < 10; $j++) {
		        $y = new RelY();
		        $y->name = "y ".($i * 10 + $j);
		        $y->rel_x_id = $x->id;
		        $y->save();
		    }
	    }   
    }
Example #2
0
 public function prepareData()
 {
     Doctrine_Manager::getInstance()->getCurrentConnection()->beginTransaction();
     $cats = array('cat1', 'cat2');
     $now = time();
     for ($i = 0; $i < 10; $i++) {
         $age = $now - $i * 1000;
         $x = new RelX();
         $x->name = "x {$i}";
         $x->category = $cats[$i % 2];
         $x->set('created_at', strftime("%Y-%m-%d %H:%M:%S", $age));
         $x->save();
         for ($j = 0; $j < 10; $j++) {
             $y = new RelY();
             $y->name = "y " . ($i * 10 + $j);
             $y->rel_x_id = $x->id;
             $y->save();
         }
     }
     Doctrine_Manager::getInstance()->getCurrentConnection()->commit();
 }