Hi guys,
I found this issue while working on my project.
when I have this piece of code :
$criteria = new CDbCriteria;
$criteria->condition='
TrainingPlanDeliveryID IN
(select TrainingplanDeliveryID from trainingplandeliverydetails where TrainingPlanID = '.$this->TrainingPlanID.')
';
$criteria->select = array('UserID');
$criteria->distinct = true;
$totalIdeliveredthisplan = Trainingplandeliverydetailsforusers::model()->findAll($criteria);
This is exactly selecting only userID from result.
But here i wanted to count the result, so I modified model()->findAll to model()->count as:
$criteria = new CDbCriteria;
$criteria->condition='
TrainingPlanDeliveryID IN
(select TrainingplanDeliveryID from trainingplandeliverydetails where TrainingPlanIDs = '.$this->TrainingPlanID.')
';
$criteria->select = array('UserID');
$criteria->distinct = true;
$totalIdeliveredthisplan = Trainingplandeliverydetailsforusers::model()->count($criteria);
Now I noticed that , this query is selecting "UserdeliveryID" which is the primary key of this table.
Anyways I could get the count by
sizeof($totalIdeliveredthisplan)
with findAll(),But i want to know why is this happening wrong when I use count()