How to create a multilevel dropdown with query like this?
SELECT kode, nama
FROM alat
WHERE id
IN (
SELECT id_alat
FROM mutasi_alat
WHERE id
IN (
SELECT id
FROM mutasi_alat
WHERE id
IN (
SELECT MAX( id ) AS id
FROM mutasi_alat
GROUP BY id_alat
)
)
AND id_cabang =4
)
public function actionFilterCabang()
{
$data=Yii::app()->db->createCommand("select kode,nama from alat where id in
(select id_alat from mutasi_alat where (id in (select id from mutasi_alat where id in
(select max(id) AS id from mutasi_alat group by id_alat)) and (id_cabang = '".((int)$_POST['id_cabang'])."')))");
$row=$data->queryAll();
$return = CHtml::listData($row, 'id', 'kode');
foreach ($return as $dataId => $dataName) {
echo CHtml::tag('option', array('value' => $dataId), CHtml::encode($dataName), true);
}
}