I have this code
$dataProvider = new CActiveDataProvider(Categories::model()->childrenFor($categoryId));
if ($dataProvider->totalItemCount) {
$this->render('categories',array(
'dataProvider' => $dataProvider,
'city' => $city,
'category' => $category,
));
}
where childrenFor is defined as
public function childrenFor($id)
{
$this->getDbCriteria()->mergeWith(array(
'condition' => 't.parent_id = "' . $id . '"',
));
return $this;
}
In the view
<?php foreach($dataProvider->getData() as $k => $cat): ?>
...
<?php endforeach;?>
$dataProvider in a view returns me all records from table without filtering them by scope, although $dataProvider->totalItemCount returns the right number.
What is wrong in my code?