It works good, but seems that paging calculation doesn’t respect this select, so without SUM() I have many pages while there are only 2 real rows in set.
From MySQL query logs I can see that this custom select is just missing.
Can someone help me with this?
Am I wrong with something or this is an issue with the AR?
public function search()
{
$criteria=new CDbCriteria;
$criteria->select = 'sum(someField), …';
$criteria->group = 'tableId';
…
$dp = new CActiveDataProvider($this, array('criteria'=>$criteria));
$dp->setTotalItemCount(count($this->findAll($criteria)));
return $dp;
}
This come of course at the expense of one additional query (findAll), but it’s the only viable solution I’ve found that works even with multiple pages.