Exemplo n.º 1
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl('propertyType_index');
     $model = new PropertyType();
     $criteria = new CDbCriteria();
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
Exemplo n.º 2
0
 public function test_find_on_unsaved_models_including_associations()
 {
     $Property = new Property('description->', 'Chalet by the sea');
     $PropertyType = new PropertyType();
     $this->assertTrue($PropertyTypes = $PropertyType->findAll());
     $Property->property_type->add($PropertyTypes);
     $this->assertTrue($Property->save());
     $Property = new Property();
     $expected = array();
     foreach (array_keys($PropertyTypes) as $k) {
         $expected[] = $PropertyTypes[$k]->get('description');
     }
     $this->assertTrue($Properties = $Property->findFirstBy('description', 'Chalet by the sea', array('include' => 'property_type')), 'Finding including habtm associated from a new object doesn\'t work');
     foreach (array_keys($Properties->property_types) as $k) {
         $this->assertTrue(in_array($Properties->property_types[$k]->get('description'), $expected));
     }
 }