CodeIgniter Forums
when I use countAll, it's seem without deleted_at query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: when I use countAll, it's seem without deleted_at query (/showthread.php?tid=78553)



when I use countAll, it's seem without deleted_at query - asrahi - 02-06-2021

Hi!
When I use countAll(), It's seem without deleted_at query.
How can I with deleted_at when I call countAll()?


Code:
Database (4 Queries across 0 Connection)
Time    Query String
0.19 ms    SELECT COUNT(*) AS `numrows` FROM `TB_MEM` WHERE `TB_MEM`.`date_del` IS NULL
0.15 ms    SELECT COUNT(*) AS `numrows` FROM `TB_MEM`
0.1 ms    SELECT COUNT(*) AS `numrows` FROM `TB_MEM` WHERE `TB_MEM`.`date_del` IS NULL
0.22 ms    SELECT * FROM `TB_MEM` LEFT JOIN `TB_MEM_LEVEL` USING (`IDX_MEM_LEVEL`) WHERE `TB_MEM`.`date_del` IS NULL ORDER BY `date_reg` DESC LIMIT 20


I guess
first line, $model->countAllResults(false)
sec line, $model->countAll(false)
3rd line, $model->paginate(20)
list line, $model->pager

p.s I changed defualt set 'deleted_at' to 'date_del'

thank you


RE: when I use countAll, it's seem without deleted_at query - kenjis - 02-07-2021

It seems it is a bug.
There is no `countAll()` method in CodeIgniter\Model.


RE: when I use countAll, it's seem without deleted_at query - asrahi - 02-09-2021

(02-07-2021, 02:40 AM)kenjis Wrote: It seems it is a bug.
There is no `countAll()` method in CodeIgniter\Model.

How Can I know rows count when I use with model?
should I don't use $model->countAll() or $model->countAllResults() ??


RE: when I use countAll, it's seem without deleted_at query - kenjis - 02-09-2021

When you use soft deletes, you can use `countAllResults()`.

And you can use Query Builder.
https://codeigniter4.github.io/CodeIgniter4/models/model.html#working-with-query-builder
With Query Builder, you can make any SQL query.


RE: when I use countAll, it's seem without deleted_at query - asrahi - 02-13-2021

Code:
    public function countAll(bool $reset = true, bool $test = false){
        $q = $this->builder( $this->table );
        if ($this->useSoftDeletes === true) {
            $q->where($this->table . '.' . $this->deletedField, null);
        }
        return $q->testMode($test)->countAllResults($reset);
    }
I see
I used override method like this.