Welcome Guest, Not a member yet? Register   Sign In
Can I: get() and count_all_results() within the same $this->db
#1

[eluser]Matrices[/eluser]
Here's my code:

Code:
$this->db->where('username', $_POST['username']);
$this->db->where('password', $_POST['password']);
$query = $this->db->get('accounts');
$rows = $this->db->count_all_results('accounts');

I'm running into a problem where the $rows counted are ALL the rows from the database, which means the filter is only working for the first query, in the 3rd row. Is there a way that I can use the filter created within the first two lines to work for more than just the first query line? Or do I have to reintroduce the filter for the second query?
#2

[eluser]Pascal Kriete[/eluser]
All forms of get(), as well as count_all_results() reset the query, but you can use $query->num_rows() to get the row total for a query.
#3

[eluser]Matrices[/eluser]
Ah, ty. That's perfect
#4

[eluser]koorb[/eluser]
I am trying to page results, I have built up quite a complicated set of dynamic criteria to search the db on, I want the limited results and the total number of records that match the criteria. Is this possible? $query->num_rows() will only give me the number returned with limits.

TIA




Theme © iAndrew 2016 - Forum software by © MyBB