PHP Classes

SQL_CALC_FOUND_ROWS

Recommend this page to a friend!

      TPaginatedData  >  All threads  >  SQL_CALC_FOUND_ROWS  >  (Un) Subscribe thread alerts  
Subject:SQL_CALC_FOUND_ROWS
Summary:Way to increase efficiency
Messages:6
Author:Paul Lautman
Date:2006-05-06 17:36:40
Update:2006-05-16 15:27:32
 

  1. SQL_CALC_FOUND_ROWS   Reply   Report abuse  
Picture of Paul Lautman Paul Lautman - 2006-05-06 17:36:40
Neat class.
One suggestion is to use SQL_CALC_FOUND_ROWS in the original select instead of a second SELECT count(*) which should increae efficiency.

  2. Re: SQL_CALC_FOUND_ROWS   Reply   Report abuse  
Picture of Augustin BOTEANU Augustin BOTEANU - 2006-05-06 18:02:21 - In reply to message 1 from Paul Lautman
Hi

I'm glad you like the class. It's my first one submitted, and the first that i actually use a lot in my projects.

Thanks for letting me know about that tehnique. I will study the MySQL manual and make the modifications.

I also changed another few thinks like implementing in the functions that require the current page number as parameter the possibility to work well if the page number variable was not set (like you are in first page and you don't have a $_GET['current_page']). In this case the functions assume the page number is 1 (first page).

Please let me know if you found the commenting, documentation/explanations and the example sufficient to understand how to use it and how it works.

I really appreciate your feedback. Thanks.

Augustin

  3. Re: SQL_CALC_FOUND_ROWS   Reply   Report abuse  
Picture of Paul Lautman Paul Lautman - 2006-05-06 18:46:58 - In reply to message 2 from Augustin BOTEANU
> I also changed another few thinks like

Is the changed version available anywhere?

  4. Re: SQL_CALC_FOUND_ROWS   Reply   Report abuse  
Picture of Augustin BOTEANU Augustin BOTEANU - 2006-05-06 18:56:46 - In reply to message 3 from Paul Lautman
no i haven't uploaded yet.

i didn't found a good example regarding SQL_CALC_FOUND_ROWS to understand it. Can you please modify the class and comment the code you write and send it to me by e-mail?

Thanks

  5. Re: SQL_CALC_FOUND_ROWS   Reply   Report abuse  
Picture of Paul Lautman Paul Lautman - 2006-05-06 20:07:11 - In reply to message 4 from Augustin BOTEANU
I'll need to play a bit to check out the complete operation of the class.
In the meanwhile here is an example usage:

$sql = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM results ORDER BY Date DESC LIMIT $from, $max_results");
$fr = mysql_query("SELECT FOUND_ROWS()");
$rc = mysql_fetch_array($fr);
// Figure out the total number of results in DB:
$total_results = $rc['FOUND_ROWS()'];

while($row = mysql_fetch_assoc($sql)){
.
.
.
}

  6. Re: SQL_CALC_FOUND_ROWS   Reply   Report abuse  
Picture of Paul Lautman Paul Lautman - 2006-05-16 15:27:32 - In reply to message 5 from Paul Lautman
I have added the new code as requested and have sent you copies.

Enjoy!