Now I want to run in the Model B to a search() through CDbCriteria by doing:
$criteria->select = array('COUNT(site_no) AS site_count');
My CActiveDataProvider doesn’t return the Model B with ‘site_count’. It still gives the attributes back from the Model A.
How can I use $criteria->select with column aliases? Basically how can I use a derived Model B, whose attributes are completely derived attributes from Model A. The derived formulas are complicated, so I can’t just do a afterFind() on the attributes after I retrieved the data.
Have you overridden the model() method in your derived class?
/**
* Returns the static model of the specified AR class.
* @return X the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}