Welcome Guest, Not a member yet? Register   Sign In
How to get total records from Pager
#5

(This post was last modified: 09-23-2022, 03:28 AM by frocco.)

(09-23-2022, 02:13 AM)captain-sensible Wrote: had a quick look through some previous code of mine and found this:

Code:
$handle= new PortfolioModel();
$mycount= $handle->isEmptyMens();
$count= $mycount["COUNT(*)"];
if($count ==0)

It was when i was playing with a web for my daughter, fashion web.

now i coudn't  find the code for the method isEmptyMens();  its one of my model->method names and will most certainly contain
contain stand model methods for geting data , and in the docs

also  what I can say is that
Code:
$handle= new PortfolioModel();
//here i am instantiating a Model based on CI4 model, where you set allowed fields etc.
//$handle is my  none imagination way of  naming the instance
$mycount= $handle->isEmptyMens();
//this will be using  one of the ci4 methods documented in "modelling data" in the docs
//something probably like findAll() but don't quote me on that , i have a bad memory on which work with objects , those that might use arrays


$count= $mycount["COUNT(*)"];

in the above i leverage what a CI4 model standard method , in the docs, (modelling data) to get what i want 

I use an sqlite3 database for all my web. That is my approach to getting an actual count from  a class->method() object.
Now it hints to me that I also could find a direct way of using CI4 model and one of its ready methods ,to a get a count THEN. There may very well be a straight forward
way now to use CodeIgniter Model to get a Count. But i've i have shown using some lateral thinking you can get a count using CodeIgniter Model class and its methods.
In later code i just thought horses fore courses and just switched to Query builder to get the job done.

Thanks for getting back to me.
The only way I found is to use two result sets based on same filtered query.

$result->like('cat_title', trim($locate) . '%');
$result2->like('cat_title', trim($locate) . '%');
$results2 = $result2->countAllResults();
$results = $result->paginate(5);
Reply


Messages In This Thread
How to get total records from Pager - by frocco - 09-22-2022, 10:39 AM
RE: How to get total records from Pager - by frocco - 09-23-2022, 03:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB