Hi,
i use a select criteria.
Example:
$this->_criteria = new CDbCriteria();
$this->_criteria->select = 't.id, t.cim, (t.nap_'.$nowday.'_0) as start_time, (t.nap_'.$nowday.'_1) as end_time, t.telszam, t.pid, t.kid, ifnull(k.kid, 1000) as sorrend';
$this->_criteria->order = 'sorrend asc, t.id asc';
$this->_criteria->join = 'LEFT JOIN tbl_kiemeles_fizetve k ON (t.pid=k.kuid)';
if(isset($_POST['example'])) {
$this->_examplecriteria = new CDbCriteria();
$this->_examplecriteria->condition = 'example = 1';
$this->_criteria->mergeWith(array(
'with' => array(
'hirdetesextra' => array(
'select' => false,
'alias' => 'e',
'joinType' => 'INNER JOIN',
),
),
));
$this->_criteria->mergeWith($this->_examplecriteria);
}
If the $_POST[‘example’] empty, the select is great, but is it not empty the model generate alias to the field.
How to "disable" the AS?
SELECT `t`.`id` AS `t0_c0`, `t`.`cim` AS `t0_c1`, (t.nap_5_0) as start_time, (t.nap_5_1) as end_time, `t`.`telszam` AS `t0_c59`, `t`.`pid` AS `t0_c2`, `t`.`kid` AS `t0_c3`, `t`.`kid` AS `t0_c3`, 1000) as sorrend FROM `tbl_hirdetes` `t` LEFT JOIN tbl_kiemeles_fizetve k ON (t.pid=k.kuid) INNER JOIN `tbl_hirdetes_extra` `e` ON (`e`.`hirdetes_id`=`t`.`id`) WHERE example = 1 ORDER BY sorrend asc, t.id asc