Comparing
#5 with
#6
Revision #6 was created by
alrazi on Nov 21, 2017, 2:39:53 PM.
remove redundant queries
Content
[...]
```php
public function actionLists($id)
{
$countPosts = \common\models\Post::find()
->where(['category_id' => $id])
->count();
$posts = \common\models\Post::find()
->where(['category_id' => $id])[...]
->all();
if($countP (!empty($posts
>0))) {
foreach($posts as $post)
{
echo "<option value='".$post->id."'>".$post->title."</option>";
}
}
else{
echo "<option>-</option>";
}
}
```[...]