Here is my situation,
I have one model Item that have some attributes including base (base price for the item), and another model ItemPrice that holds the value for the item in a given season (another model)
so, I want to get the price of the items for a particular season:
$criteria = new CDbCriteria(array(
'with'=>array(
'itemPrices'=>array(
'select'=>array('itemPrices.base * 2 as price')
)
),
'together'=>true
));
the relations of item is as follow:
public function relations()
{
return array(
'itemPrices' => array(self::HAS_MANY, 'ItemPrice', 'item_id', 'joinType'=>'INNER JOIN'),
);
}
Note: I added an attribute price in the model Item to hold the calculated value, but always return null.
I digged into the code needed to be able to get this column and I found that the value is not there because when executing the query the alias price is not changes as the other attributes, changing to a generated alias, say t0_c1, results in getting the calculated value in another attribute, but is not what I want.
can anyone help me please ?!
PD: I’m attaching the schema i’m currently using.