Welcome Guest, Not a member yet? Register   Sign In
when I use countAll, it's seem without deleted_at query
#1

(This post was last modified: 02-06-2021, 10:48 PM by asrahi.)

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
Reply
#2

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

(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() ??
Reply
#4

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

And you can use Query Builder.
https://codeigniter4.github.io/CodeIgnit...ry-builder
With Query Builder, you can make any SQL query.
Reply
#5

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB