Welcome Guest, Not a member yet? Register   Sign In
Raw Query Pagination
#2

(This post was last modified: 10-30-2021, 02:46 AM by captain-sensible. Edit Reason: added something i forgot )

whats the advantage of that when you are using "*" which gets all.

in a model you define fields:

Code:
class BlogModel extends Model

{

protected $table      = 'blog';
protected $primaryKey = 'Id';
protected $allowedFields = ['title','article','image','slug','date'];
protected $limit;
protected $offset;
protected $Id;
protected $title;
protected $article;
protected $slug;


via a Controller you can get a handle to Model eg
Code:
$handle = new BlogModel();    
                     $data = [
                         'title'=>'paginate',
                        'blogs' => $handle->paginate(5),
                        'pager' => $handle->pager,
                        'date'=>$this->myDate
                    ];
in a view you can for instance

Code:
foreach($blogs as $blogy)
{



echo "<h11><a href = blogArticle/" . $blogy['slug'] .  "> ".  $blogy['slug']  ."         </a> </h11> <br> ";  



}

the main point being you can get access to all field in the table. So basically (i think)


'blogs' => $handle->paginate(5) is saying blogs is an object which contains data in all fields that were listed in my model i.e "*"


and that blogs is passed to view bundled in $data
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply


Messages In This Thread
Raw Query Pagination - by Capah.maga - 10-29-2021, 01:25 AM
RE: Raw Query Pagination - by captain-sensible - 10-30-2021, 02:45 AM
RE: Raw Query Pagination - by Capah.maga - 11-01-2021, 08:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB