Welcome Guest, Not a member yet? Register   Sign In
$query->num_rows(); // Value is not expected .. This is not the total value
#3

[eluser]soprabaixar1[/eluser]
You do not understand my question.
I have a query to the database, and I need the number of rows this query, but when using the parameter that references to "limit", example:

Code:
$query = $this->db->orderby (..., ...);
$query = $this->db->like ("...", ...);

$query = $this->db->get('mytable', 10, 20) // this
or
$query = $this->db->limit(10, 20) // or this

I can not get the total rows using:
Code:
$ query-> NUM_ROWS () / / will return 20 rows, because of the limit

My temporary solution was to create a new query to the database only to calculate the number of lines:

Code:
$query2 = $this->CI->db->like("user", ...);
$query2 = $this->CI->db->get('table');
$query2->NUM_ROWS();

The problem that the database has many records and many users access, it affects system performance. I wonder if another way to solve this.


Messages In This Thread
$query->num_rows(); // Value is not expected .. This is not the total value - by El Forum - 04-04-2011, 04:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB