I'm currently trying to shoeho sql into my criteria as it's a bit complex for me to put into cdbcriteria at the minute.
The issue is I'm only getting the very first result of the sql and I'm a little bit confused at why it's not getting the entire query. I feel like I shouldn't have to loop round as the select query should be grabbing everything and giving it a name for me to use, but apparently not!
My criteria is
public function search() {
// Waing: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->select = [
'userVariables.*',
't.*',
'MAX(CASE WHEN userVariables.user_type_variables_id = 1 THEN userVariables.value ELSE NULL END) AS Question1',
'MAX(CASE WHEN userVariables.user_type_variables_id = 2 THEN userVariables.value ELSE NULL END) AS Question2',
'MAX(CASE WHEN userVariables.user_type_variables_id = 3 THEN userVariables.value ELSE NULL END) AS Question3',
'MAX(CASE WHEN userVariables.user_type_variables_id = 4 THEN userVariables.value ELSE NULL END) AS Question4',
'MAX(CASE WHEN userVariables.user_type_variables_id = 5 THEN userVariables.value ELSE NULL END) AS Question5',
'MAX(CASE WHEN userVariables.user_type_variables_id = 6 THEN userVariables.value ELSE NULL END) AS Question6',
];
$criteria->group = "t.id";
$criteria->compare('id', $this->id, true);
$criteria->compare('event_id', $this->event_id, true);
$criteria->compare('status_id', $this->status_id, true);
$criteria->compare('checkin_status_id', $this->checkin_status_id, true);
// $criteria->compare('guest_invites', $this->guest_invites, true);
$criteria->compare('guest_of_user_id', $this->guest_of_user_id, true);
$criteria->compare('user_id', $this->user_id, true);
$criteria->compare('assign_group', $this->assign_group, true);
// $criteria->with = 'eventAttendeesGroup';
$criteria->compare('user.forename', $this->user_forename, true);
$criteria->compare('user.suame', $this->user_suame, true);
$criteria->compare('user.company', $this->user_company, true);
$criteria->compare('user.telephone', $this->user_telephone, true);
$criteria->compare('user.dob', $this->user_dateofbirth, true);
$criteria->compare('event.name', $this->event_name, true);
$criteria->order = 'user.suame ASC';
$criteria->with = array('user','event','userVariables');
$criteria->together = true;
retu new CActiveDataProvider($this, array(
'criteria' => $criteria,
//manages the pagination and how many users appear on the onsite reg page
'pagination'=>array('pageSize'=>50),
//'pagination'=>false,
));
}
