Hey guys! I would like to make a simple page pagination, but now I have a following problem and really hope on some help here
I tried to see the documentation , how to create pagination, but there was only example using ActiveRecord class which I am not using.
This is my query to fetch some data from database, inside a model:
public function getCarLog($car_id){
$query = new Query;
$query ->select('car_blog_id, blog_title, car_blog.car_id, blog_text, blog_type,
car_blog.created, car_blog_album_id, blog_id, photo, users.id, username, avatar')
->from('car_blog')
->where(['car_blog.car_id' => $car_id,])
->leftJoin('car_blog_album', 'car_blog_album.blog_id = car_blog.car_blog_id')
->leftJoin('users', 'users.id = car_blog.user_id')
->groupBy('car_blog_album.blog_id');
$command = $query->createCommand();
$data = $command->queryAll([\PDO::FETCH_OBJ]);
$numberOfCarLogs = count($data);
$this->numberOfCarLogs = $numberOfCarLogs;
return $data;
}
And this code is in the controller:
public function actionIndex(){
$userCarsModel = new UserCars();
$car_id = Yii::$app->request->get('car_id');
$carData = $userCarsModel->getCarDataByCarId($car_id);
$car_log = new UserCarBlog();
return $this->render('index', [
'carData' => $carData,
'car_logs' => $car_log->getCarLog($car_id),
]);
}
So, how can i make a pagination? 2 hours searching in google just showed me how to create it with AR class, but as i said, i am not using it here.
At least give me some advices or something…please