Welcome Guest, Not a member yet? Register   Sign In
Success to CI4 Last Version
#11

(This post was last modified: 10-01-2020, 01:55 AM by nc03061981.)

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

(This post was last modified: 10-01-2020, 05:59 PM by nc03061981.)

(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




Theme © iAndrew 2016 - Forum software by © MyBB