CDbCriteria Error


I am new to Yii and am trying out the CDbCriteria command. My query is

$criteria=new CDbCriteria;

$criteria->group = 'unit.supplier_id';

$criteria->join = 'left join unit where unit.supplier_id =';

$criteria->select = 'supplier.*, count(supplier_id) as unitcount';


This produces the sql code

SELECT supplier.*, count(supplier_id) as unitcount FROM 'Supplier' left join unit where unit.supplier_id = GROUP BY unit.supplier_id LIMIT 10

My problem is how to access the unitcount element of the resultset. When I try to access this in the view as follows

   <td><?php echo CHtml::encode($model->unitcount); ?></td>

I get the following error




Property "Supplier.unitcount" is not defined.


ActiveRecord is looking for a model attribute named unitcount, which of course doesn't exist. So how do I access resultset named elements such as that shown above.



Declare a public member in the AR class named unitcount.


Thanks for the quick reply. That worked fine.

PS> I come from a Java/J2EE/Grails background and this is my first PHP project. So far I am very impressed with Yii. Congratulations on a great framework.