Welcome Guest, Not a member yet? Register   Sign In
Pagination with Custom model
#11

Add pager in your controller :
PHP Code:
<?php namespace App\Controllers;

use 
App\Models\CustomModel;

class 
Annunci extends BaseController{

  public function index() {
     
     $db 
db_connect();
     $model = new CustomModel($db);
     $annunci $model->annunci();
     
$annunci $model->pager;

     return view('cet',$annunci);

  }
}

?>

And change your model from : 
PHP Code:
public function annunci(){
  return $this->db->table('annunci')
 ->
orderBy('data''DESC')
 ->
get()
 ->
getResultArray();



To : 
PHP Code:
public function annunci(){
  return $this->table('annunci')
 ->
orderBy('data''DESC')
 ->
paginate(4'annunci'); // 4 for limiting data


Reply


Messages In This Thread
Pagination with Custom model - by AndreaL - 12-31-2020, 03:59 AM
RE: Pagination with Custom model - by InsiteFX - 12-31-2020, 12:27 PM
RE: Pagination with Custom model - by AndreaL - 01-04-2021, 03:03 AM
RE: Pagination with Custom model - by seunex - 01-04-2021, 04:01 AM
RE: Pagination with Custom model - by includebeer - 01-04-2021, 05:33 AM
RE: Pagination with Custom model - by AndreaL - 01-07-2021, 02:31 AM
RE: Pagination with Custom model - by rmcdahal - 01-04-2021, 06:29 AM
RE: Pagination with Custom model - by includebeer - 01-07-2021, 08:19 AM
RE: Pagination with Custom model - by AndreaL - 02-09-2021, 03:41 AM
RE: Pagination with Custom model - by MuhAnhar - 01-12-2021, 06:06 AM
RE: Pagination with Custom model - by includebeer - 01-12-2021, 03:46 PM
RE: Pagination with Custom model - by InsiteFX - 02-09-2021, 07:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB