示例#1
0
 /**
  * @param type $iduser id of the user which favorite events are required
  * @param type $pgs number of elements for page to specify pagination attribute of CListView
  * @return CActiveDataProvider with the favorite events of the given user, which can be used to show the events using a 
  */
 public static function getEventosFavoritosUser($iduser,$elsPag)
 {
     $modelE = self::model();
     $favRule = array('idevento',Favoritos::getFavoritosUser($iduser));
     $criterio = new CDbCriteria();
     // Passa-se o nome do atributo e os valores in (val1,val2,val3,...)
     $criterio->addInCondition($favRule[0],$favRule[1]);
     $criterio->select = array(
                                 'idevento',
                                 'titulo',
                                 'dtinicio',
                                 'dtfim',
                                 'lat',
                                 'lon'
                         );
     $criterio->addCondition('dtfim > '.(new CDbExpression('NOW()')));
     $criterio->order = 'dtinicio DESC';
     return new CActiveDataProvider($modelE,
                                         array(
                                             'criteria'=>$criterio,
                                             'pagination'=>
                                                     array(
                                                        'pageSize'=>$elsPag
                                                     )
                                         )
                );
 }