Hi All I have a CActiveDataProvider with a criteria.
I need it to return all records, but it is only returning one.
It looks like the problem is with the count as it is using a distinct.
How do I get it to return all records?
63 /**
64 * @return array relational rules.
65 */
66 public function relations()
67 {
68 // NOTE: you may need to adjust the relation name and the related
69 // class name for the relations automatically generated below.
70 return array(
71 'patientScheduleVisitLookups' => array(self::HAS_MANY, 'PatientScheduleVisitLookup', 'patient_id'),
72 'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
73 );
74 }
75
76 /**
77 * @return array customized attribute labels (name=>label)
78 */
79 public function attributeLabels()
80 {
81 }
82
83 /**
84 * Retrieves a list of models based on the current search/filter conditions.
85 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
86 */
87 public function searchPeople()
88 {
89 $criteria=new CDbCriteria;
90 $criteria->compare('t.active_state',$this->active_state,true);
91 $criteria->compare('t.patient_id',$this->patient_id,true);
92 $criteria->compare('sv.visit_date',$this->appointment_date,true);
93 $criteria->together = true ;
94 $criteria->with = array('patientScheduleVisitLookups.scheduleVisits'=>array('joinType'=>'LEFT JOIN'),'user'=>array('jo inType'=>'LEFT JOIN'));
95
96 return new CActiveDataProvider($this, array(
97 'criteria'=>$criteria,
98 'pagination'=>array('pageSize'=>30),
99 ));
100 }
Sample Query out put.
[sql]
SELECT COUNT(DISTINCT t.id) FROM patients t LEFT OUTER JOIN patient_schedule_visit_lookup patientScheduleVisitLookups ON (patientScheduleVisitLookups.patient_id=t.id) LEFT JOIN schedule_visits scheduleVisits ON (patientScheduleVisitLookups.schedule_visits_id=scheduleVisits.id) LEFT JOIN users user ON (t.user_id=user.id) WHERE (t.patient_id LIKE ‘%1642%’)
[/sql]
[sql]
SELECT t.id AS t0_c0, t.type AS t0_c1, t.active_state AS t0_c2, t.report_haq AS t0_c3, t.report_radai AS t0_c4, t.report_past AS t0_c5, t.patient_id AS t0_c6, t.user_id AS t0_c7, user.id AS t3_c0, user.email AS t3_c1, user.email_hash AS t3_c2, user.password AS t3_c3, user.user_title AS t3_c4, user.first_name AS t3_c5, user.last_name AS t3_c6, user.phone_home AS t3_c7, user.phone_mobile AS t3_c8, user.fax AS t3_c9, user.dob AS t3_c10, user.active_state AS t3_c11, user.user_name AS t3_c12, user.no_email AS t3_c13 FROM patients t LEFT JOIN users user ON (t.user_id=user.id) WHERE (t.patient_id LIKE ‘%1642%’) LIMIT 30[/sql]