<?php
class MyActiveDataProvider extends CActiveDataProvider {
protected function calculateTotalItemCount() {
$baseCriteria=$this->model->getDbCriteria(false);
if ($baseCriteria!==null)
$baseCriteria=clone $baseCriteria;
//You can get real records count only in this way (when you use JOIN and GROUP BY)
$count=count($this->model->findAll($this->getCriteria()));
$this->model->setDbCriteria($baseCriteria);
return $count;
}
}
?>
model search function
<?php
public function searchbygroup()
{
$criteria=new CDbCriteria;
//custom query
$criteria->select=array('*,concat(documentid,"_",userid) as groupid,count(documentid) as downloadcount');
//Add Different Condition
$criteria->compare('userid',$this->userid,true);
$criteria->addCondition("documentid IN ('$this->documentid')");
$criteria->addBetweenCondition('createdon',$this->datefrom,$this->dateto);
// group by , if need
$criteria->group='groupid';
//return new CActiveDataProvider($this, array( 'criteria'=>$criteria, ));
return new MyActiveDataProvider($this,array('criteria'=>$criteria));
}
?>
I’m a newbie, my apologies, but where I have to change your code so I can calculate the score based on the average of three columns from another table?