Hi All,
I have a CAtiveDataProvider the has a few joins.
96 public function searchPeople()
97 {
98
99 $criteria=new CDbCriteria;
100 $criteria->compare('t.active_state',$this->active_state,true);
101 $criteria->compare('t.patient_id',$this->patient_id,true);
102 $criteria->compare('sv.visit_date',$this->appointment_date,true);
103 $criteria->distinct = false;
104 $criteria->with = array('patientScheduleVisitLookups'=>array('joinType'=>'LEFT JOIN'), 'patientScheduleVisitLookups.sc heduleVisits'=>array('joinType'=>'LEFT JOIN') );
105
106 return new CActiveDataProvider($this, array(
107 'criteria'=>$criteria,
108 'pagination'=>array('pageSize'=>30),
109 ));
110 }
My relations are as follows
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_ONE, 'PatientScheduleVisitLookup', 'patient_id'),
72 'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
73 );
74 }
The problem I’m having is this should return multiple rows but only one is coming through.
The problem is the count is doing a distinct and I don’t want it too.
Problem query.
[sql]SELECT COUNT(DISTINCT t
.id
) FROM patients
t
LEFT JOIN patient_schedule_visit_lookup
patientScheduleVisitLookups
ON (patientScheduleVisitLookups
.patient_id
=t
.id
) LEFT JOIN schedule_visits
scheduleVisits
ON (patientScheduleVisitLookups
.schedule_visits_id
=scheduleVisits
.id
) WHERE (t.patient_id LIKE ‘%1642%’)
[/sql]
How do I remove the distinct from the query above?
What I expect to get out.
[sql]10469 active false false false 1642JD 15727 95621 10469 122571 122571 NULL NULL 2012-07-18 00:00:00 2012-07-18 00:00:00 NULL 750 mg 32472 2012-09-11 11:52:20 false 13548 false false
10469 active false false false 1642JD 15727 95622 10469 122572 122572 NULL NULL 2012-08-01 00:00:00 2012-08-01 00:00:00 NULL 750 mg 32472 2012-09-11 11:52:20 false 13548 false false
10469 active false false false 1642JD 15727 95623 10469 122573 122573 NULL NULL 2012-08-29 00:00:00 2012-08-29 00:00:00 NULL 750 mg 32472 2012-09-11 11:52:20 true 13548 false false
10469 active false false false 1642JD 15727 95624 10469 122574 122574 NULL NULL 2012-09-28 00:00:00 2012-09-28 00:00:00 NULL 750 mg 32472 2012-09-11 11:52:20 true 13548 false false[/sql]
thanks,
Paul.