I am trying to execute the following statement:
$a = A::model()->with(array(
'b'=>array('select'=>'b.name'),
'c.d'
))->findAll(
array(
'select'=>array("t.*, FORMAT(ABS(t.amount), 2, 'en_IN') as amount_fmt"),
'condition'=>'id = :id',
'params'=>array(':id'=>$id)
));
The statement executes without any error. But i dont get the columns of the table t
, i.e., the table a
. Only the following columns of the table a
are available:
a->id
a->amount_fmt
For instance, I am not able to retrieve a->amount.
But, if the above statement is executed with a small modification:
$a = A::model()->with(array(
'b'=>array('select'=>'b.name'),
'c.d'
))->findAll(
array(
'select'=>array("`t`.`amount` as `t0_c5`, FORMAT(ABS(t.amount), 2, 'en_IN') as amount_fmt"),
'condition'=>'id = :id',
'params'=>array(':id'=>$id)
));
Now, a->amount is available (amount
is the sixth column in table a
).
Am i doing something wrong in the first statement, because i do not want to remember the column no. to get the correct result?