Register now or log in to join your professional community.
$criteria = new CDbCriteria(); $criteria->select = 'type , seen, count(1) As counts'; $criteria->condition = 'mb = :mb AND deleted = false AND archived = false'; $criteria->params = array(':mb'=>$mb); $criteria->group = 'type ,seen'; $counters = $this->findAll($criteria); the problem is How can I get the value for (counts ) if its not as attribute on class? I try to $counters[0]->counts but not worked
You cant access the value unless its an attribute on the model (or) and attribute on the table,
quick solution :
on the model file add new attribute (member variable) and use it in the query
class xxModel {
public $countOfX;
}
$criteria = new CDbCriteria(); $criteria->select = 'type , seen, count(1) As countOfX'; $criteria->condition = 'mb = :mb AND deleted = false AND archived = false'; $criteria->params = array(':mb'=>$mb); $criteria->group = 'type ,seen'; $counters = $this->findAll($criteria);
Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.