Yii dataprovider和分页不适用于$ criteria-> true

时间:2015-10-26 09:09:42

标签: php yii

我为dataprovider创建了一个$criteria。 如果$criteria->together = true我有更多页面,则不会显示所有记录。 dataprovider发现它并没有显示出来。 Displaying 1-1 of 5 results.我只有3页(3个结果)。  如果我不使用$criteria->together,则条件不起作用,但分页是正确的。 这是我的$ criteriadataprovider

 $criteria = new CDbCriteria;
 $list_fenttart = UserAndApartmanPrice::getFenttartasList($_GET["fenttart"]);
 $list_elad = UserAndApartmanPrice::getPriceList($_GET["ar"]);

 $criteria->together = true;
 $criteria->with = array(
     'price_elad' => array(
          'condition' => 'price_elad.main != :main AND price_elad.valuta = :valuta AND price_elad.price BETWEEN :value1 AND :value2',
          'params' => array(
              ':main' => 10,
              ':valuta' => 1,
              ':value1' => $list_elad[0],
              ':value2' => $list_elad[1],
          )
      ),
      'price_fenttart' => array(
          'condition' => 'price_fenttart.main = :main2 AND price_fenttart.valuta = :valuta2 AND price_fenttart.price BETWEEN :value12 AND :value22',
          'params' => array(
              ':main2' => 10,
              ':valuta2' => 1,
              ':value12' => $list_fenttart[0],
              ':value22' => $list_fenttart[1],
          )
      ),
      'apartman',
      'price',
      'user',
 );

 $criteria->addCondition("t.active = 1 AND t.active_at > '{$currdate}' AND apartman.active = 1 AND apartman.function_3 = 0 AND user.active = 1");

 $dataProvider = new CActiveDataProvider(
     'UserAndApartman', 
     array(
         'criteria' => $criteria,
         'sort' => array('defaultOrder'=>'t.create_at DESC', ),
         'pagination' => array('pageSize' => 2, ),
     )
 );

这是UserAndApartman模型的关系:

'apartman' => array(self::BELONGS_TO, 'Apartmans', 'apartmans_id', 'with' => 'apartman_images'),
'price' => array(self::HAS_MANY, 'UserAndApartmanPrice', 'user_and_apartman_id'),
'price_elad' => array(self::HAS_MANY, 'UserAndApartmanPrice', 'user_and_apartman_id'),
'price_fenttart' => array(self::HAS_MANY, 'UserAndApartmanPrice', 'user_and_apartman_id'),
'user' => array(self::BELONGS_TO, 'Users', 'user_id'),

0 个答案:

没有答案