Hi All!
Can i ask you for a little help?
I have a complex query used with createCommand(), and i don’t know, ho to use CPagination with it.
my code is (from yii-blogdemo-enhanced, google code):
public function findTagWeights($limit=20)
{
$sql="SELECT name, COUNT(postId) AS weight
FROM Tag, PostTag
WHERE Tag.id=PostTag.tagId
GROUP BY name
HAVING COUNT(postId)>0
ORDER BY weight DESC
LIMIT $limit";
$rows=$this->dbConnection->createCommand($sql)->queryAll();
$total=0;
foreach($rows as $row)
$total+=$row['weight'];
$tags=array();
if($total>0)
{
foreach($rows as $row)
$tags[$row['name']]=8+(int)(16*$row['weight']/($total+10));
ksort($tags);
}
return $tags;
}
How can i use this code with pagination instead of using $limit?
I can’t figure this out.