• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Success to CI4 Last Version

#11
CI4 compressed output, so i do not to do that
Thanks

Here's what I learned for quick help from the CI4 community:

Ask clearly and specifically, you will get a quick and clear answer

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply

#12
(09-30-2020, 11:37 PM)someone Wrote: We're planning to use CI4 for our CRM and online order application. Before that, we used CI3 to our real estate website Smile

Now, CI4 looks much better. Thanks

After rewrite my project with CI4 and learn about CI4, that's best

New knowledge from InsiteFX
- any function in Model can return Model and can use it to point anything that it has
Thanks

Only Update Framework by Composer
(10-01-2020, 06:17 AM)captain-sensible Wrote: you can try :

$ php composer.phar  update codeigniter4/framework --no-dev

Thanks

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply

#13
Lightbulb 
In your Controller
PHP Code:
$pager = \Config\Services::pager();
 
$model = new TestModel();
 
 
$this->data['root'] = [
            'data'  => $model->paginate(10),
            'pager' => $model->pager
        
]; 

In your Model, Overrite system function paginate
PHP Code:
public function paginate(int $perPage nullstring $group 'default'int $page nullint $segment 0)
 {
 
$this->table 'lott_index';
 
$pager = \Config\Services::pager(nullnullfalse);

 if (
$segment)
 {
 
$pager->setSegment($segment);
 }

 
$page $page >= $page $pager->getCurrentPage($group);

 
// Get Total Records - Your query here to get Total Records - example below
 
$sql  "SELECT COUNT(id) AS total FROM lott_index LIMIT 1";
 
$query $this->db->query($sql);
 if (
count($query->getResult()) == 1) {
 
$row  $query->getRow();
 
$total intval($row->total);
 } else {
 
$total 0;
 }

 
// Store it in the Pager library so it can be paginated in the views.
 
$this->pager $pager->store($group$page$perPage$total$segment);
 
$perPage    $this->pager->getPerPage($group);
 
$offset      = ($page 1) * $perPage;

 
// Your query here to get Data For Per Page, example below
 
$query  " SELECT *";
 
$query .= " FROM lott_index";
 
$query .= " ORDER BY dates";
 
$query .= " LIMIT ".$offset.",".$perPage;
 
$query  $this->db->query($query);

 return 
$query;
 } 

This working fine for custom QUERY...

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.