1,会议桌型号名称矿石会议领域ID,标题,开始时间,创建者关系'MeetingParticipants'=> array(self :: HAS_MANY,'MeetingParticipants','meeting_id'),
2,core_meeting_participant表
模型名称是meeting_participant
fild是id,meeting_id,参与者ID,group_idMeeting_participant中的关系
'meeting'=> array(self :: BELONGS_TO,'CoreMeeting','meeting_id'),'group'=> array(self :: BELONGS_TO,'MeetingGroup','group_id'),
3,core_meeting_group型号名称为MeetingGroup字段是id,group_name
我在会议模型中的搜索过滤器是
公共函数search(){
$group=filter_var($_REQUEST['group'], FILTER_SANITIZE_STRING);//contain group name
$criteria=new CDbCriteria;
$user_id = Yii::app()->user->id;
$criteria->compare('id',$this->id);
$criteria->compare('title',$this->title,true);
$criteria->with=array('MeetingParticipants'=>array("select"=>"*"),'MeetingParticipants.group'=>array('select'=>'id,group_name'));
if(isset($this->start_time) && !empty($this->start_time))
$criteria->compare('start_time',date("Y-m-d", strtotime($this->start_time)), true);
$criteria->compare('created_by',$user_id);
if(isset($group)&&!empty($group))
$criteria->compare('group.group_name',$group);
$criteria->together = true;
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
I have created 4 meetings each metings have atleast 5 participants each participants belogns to a meeting group i want list all meetings with the following filed meeting title,groups and meeting time.
my problem is if i enable $criteria->together = true; if the meeting has more than 10 participants that will show only 1 meeting in grid view. if i disable this that will shows all but i cant search with the meeting name.
sql小提琴链接是http://sqlfiddle.com/#!9/fdaacf完整的SQL转储https://pastebin.com/NtpMuCpE
CDbCriteria
-> together
属性的文档: