Advertisement
Guest User

aUbilla

a guest
Jul 10th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. PacienteController:
  2.  
  3. public function actionAdmin() {
  4.         //$model = new Paciente('search');
  5.         $model = new Usuario('searchWithRelation');
  6.         $model->unsetAttributes();  // clear any default values
  7.         if (isset($_GET['Usuario'])) {
  8.             $model->attributes = $_GET['Usuario'];
  9.         }
  10.  
  11.         $this->render('admin', array(
  12.             'model' => $model,
  13.         ));
  14.     }
  15.  
  16. Modelo Usuario:
  17.  
  18. public function searchWithRelation() {
  19.         // @todo Please modify the following code to remove attributes that should not be searched.
  20.         $criteria = new CDbCriteria;
  21.  
  22.         $criteria->together = true;
  23.         $criteria->with = array('paciente');
  24.        
  25.         $criteria->compare('id', $this->id);
  26.         $criteria->compare('rut', $this->rut, true);
  27.         $criteria->compare('nombre', $this->nombre, true);
  28.         $criteria->compare('apellidoPaterno', $this->apellidoPaterno, true);
  29.         $criteria->compare('apellidoMaterno', $this->apellidoMaterno, true);
  30.         $criteria->compare('estado', 1);
  31.  
  32.         return new CActiveDataProvider($this, array(
  33.             'pagination' => array(
  34.                 'pageSize' => 15,
  35.             ),
  36.             'criteria' => $criteria,
  37.         ));
  38.     }
  39.  
  40. CGridView de Pacientes:
  41. 'dataProvider' => $model->searchWithRelation(), //cargo modelo usuarios que son tipo paciente.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement