Olá, alguém poderia me ajudar a implementar uma paginação de resultados? tenho o modelo mvc abaixo
Controller
<?php
// Load All Posts
public function index(){
$posts = $this->postModel->getPosts();
$data = [
'posts' => $posts
];
$this->view('posts/index', $data);
}
?>
Model
<?php
// Get All Posts
public function getPosts(){
$this->db->query("SELECT *,
posts.id as postId,
users.id as userId
FROM posts
INNER JOIN users
ON posts.user_id = users.id
ORDER BY posts.created_at DESC;");
$results = $this->db->resultset();
return $results;
}
View
<?php foreach($data['posts'] as $post) : ?>
<div class="card card-body mb-3">
<h4 class="card-title"><?php echo $post->title; ?></h4>
<div class="bg-light p-2 mb-3">
Written by <?php echo $post->name; ?> on <?php echo $post->created_at; ?>
</div>
<p class="card-text"><?php echo $post->body; ?></p>
<a class="btn btn-dark" href="<?php echo URLROOT; ?>/posts/show/<?php echo $post->postId; ?>">More</a>
</div>
<?php endforeach; ?>
Como fazer a paginação ?