Call to a member function count() on a non-object

ver. Yii 2.0




public function actionNews()

	{

			$query = News::find()->orderBy('id')->all();

		

			$pages = new Pagination([

				'totalCount' => $query->count(),

				'defaultPageSize' =>10,

			]);



Call to a member function count() on a non-object

?

‘totalCount’ => count($query),

1 Like

I do this, but next step…

$models = $query->offset($pages->offset)->limit($pages->limit)->all();

as result

Replying to Call to a member function offset() on a non-object