1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $max = $this->select()
->from($this, array(
'etudiant_id',
'periode_id',
'versionmax' => 'max(ce_version)'))
->where('etudiant_id = "'.$etudiant.'"')
->group(array('etudiant_id', 'periode_id'));
$select = $this->select()->setIntegrityCheck(false);
$select->from(array('CE' => $this))
->join(
array('CEMAX'=> $max),
'etudiant_id = CEMAX.etudiant_id',
array()
)
->where('CE.etudiant_id = 1 and CE.periode_id = CEMAX.periode_id AND CE.ce_version = CEMAX.versionmax')
->order('ce_version', 'DESC');
$result = $this->fetchAll($select)->toArray(); |