Tutorial - Error message

Hi All,

I am new to Yii and am following the examples in “The Definitive Guide to Yii 2.0”.

I am currently stuck at section 2.6 Working with Databases. I have copied the codes from the guide and put them into the relevant places, but I am getting the attached error message -

How should I proceed? Is this a pagination error?

Thanks in advance.

That’s PHP syntax error. ]); ->offset(

Hi Alexander,

Thanks for responding, sorry I should have attached the source code. The screen shot was the error message thrown out by Yii.

Here is the source code(taken from the Definitive Guide), doesn’t look like there is a syntax error.

<?php

namespace app\controllers;

use yii\web\Controller; 
use yii\data\Pagination; 
use app\models\Country;

class CountryController extends Controller 
{
    public function actionIndex() 
    {
        $query = Country::find();
        $pagination = new Pagination([ ’defaultPageSize’ => 5, ’totalCount’ => $query->count(), ]);
        $countries = $query->orderBy(’name’) ->offset($pagination->offset) ->limit($pagination->limit) ->all();

        return $this->render(’index’, [ ’countries’ => $countries, ’pagination’ => $pagination, ]);
    }
} 

?>

Looks OK except quotes. The error message displays different code though and it displays code that is really executed. Maybe you have problems saving code or editing in the wrong place.