In Training I want to have an attribute "total_nr" and I want to do something like:
$total_sql="(select sum(here I want to select the test attribute) from Appointment a where a.id_T=t.id_T)";
$criteria->select=array(
'*',
$total_sql.' as total_nr'
);
How can I do it when it is not an actual column in the table?
You may declare a public variable $total_nr in Training model.
public $total_nr;
Then the query will automatically fill it with the result of the total count which you’ve selected as ‘total_nu’, if you are working with CActiveRecord.