我正在创建一个按用户分组的表,并希望在那里获取最新更新。 我正在用group by对三个表执行联接,group by只是以我需要按desc顺序获取的asc顺序拾取记录。
$this->DigitalServiceProvider->virtualFields['status'] = "VD.status";
$this->DigitalServiceProvider->virtualFields['video_id'] = "VD.video_id";
$this->DigitalServiceProvider->virtualFields['finish_date'] = "VD.date";
$this->DigitalServiceProvider->virtualFields['scheduled'] = "CD.scheduled";
$this->DigitalServiceProvider->virtualFields['finished'] = "CD.finished";
$this->DigitalServiceProvider->virtualFields['start_time'] = "CD.created";
$this->DigitalServiceProvider->virtualFields['end_time'] = "CD.end_time";
$this->DigitalServiceProvider->virtualFields['version'] = "CD.version";
$this->DigitalServiceProvider->virtualFields['action'] = "CD.action";
$dspOpt = array(
'fields' => array(
'DigitalServiceProvider.*',
'status',
'finish_date',
'video_id',
'scheduled',
'finished',
'start_time',
'end_time',
'version',
'action',
),
'conditions' => array(
'dsp_operational_state' => 1,
'dsp_video_support' => 1,
),
'joins' => array(
array(
'table' => 'video_dsps',
'alias' => 'VD',
'type' => 'left',
'conditions' => array(
'DigitalServiceProvider.id = VD.dsp_id',
'VD.video_id' => $id
),
),
array(
'table' => 'content_deliveries',
'alias' => 'CD',
'type' => 'left',
'conditions' => array(
'DigitalServiceProvider.id = CD.dsp_id',
'CD.video_id' => $id,
),
),
),
'group'=>array('CD.dsp_id'),
'order'=>array('CD.id'=>'desc')
);
$dsps = $this->DigitalServiceProvider->find('all', $dspOpt);