It’s the default as generated from the crud command:
My Object is called "Stadt":
StadtController.php:
public function actionList()
{
$criteria=new CDbCriteria;
$pages=new CPagination(Stadt::model()->count($criteria));
$pages->pageSize=self::PAGE_SIZE;
$pages->applyLimit($criteria);
$models=Stadt::model()->findAll($criteria);
$this->render('list',array(
'models'=>$models,
'pages'=>$pages,
));
}
a print_r($models) returns the found models correctly.
I have seen, that the Pager is missing in the views/admin.php, too.
Ah! I just have found a nice hint: Stadt::model()->count($criteria) returns 1 - that’s wrong since there are about 8000 found without the DefaultScope.
Now, is a bug in the count function! (?) - or does the count function just ignore the DefaultScope? Then it is a missing feature …
Placing a $pages=new CPagination(8000); works fine!
oops, sorry for double-posting this one. Is it possible to delete his own postings anyhow ?
Have you tried running the generated SQL in a database management software? Due to lack of aggregation functions I think you used grouping instead of ordering.
No, i intended to use sql GROUP. "Stadt" contains every City in Germany including their zipcode, and because almost every district in Germany uses an own zipcode, there often are more than 10 zipcodes for one city. Ordering them by sql GROUP only lists every available city once with the first valid zipcode. This is intended and working very good so far.
I can understand that the count(*) function can not be possible on every thinkable scope that could be assigned to a model, but GROUP is a very commonly used function, so i think it should be implemented?
Using the Yii trace function i come to the following conclusion: