|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I just set up a search engine using MySQL and Perl DBI. I was wondering if MySQL can somehow determine how many rows were returned by the query. I tried numerous sources, and the basic idea I got was that it was not possible to count the # of rows returned using MySQL. The problem is that I want to display for example the first 20 results on the 1st page, the next 20 on the next page and so forth depending on the # of returned rows. I could use the feautre of MySQL that retrieves for example entries 1-20.. or whatever #'s you designate and just set up lets say like 10 pages which would show results (page 1 would show 1-20. page 2 would show 21-40, etc.) However i dont like this method because if the query returned 15 responses, it would be stupid for the user to have an option to go to page 2 , 3, or 4 because those pages would be blank..
umm, hopefully you got all that .. thanks a lot. |
|
#2
|
|||
|
|||
|
Doesn't $sth->rows work for you?
ie: (From the first page in the DBI::mysql man page) $dbh = DBI->connect($driver,$user,$database); $sth = $dbh->prepare("Select * from test"); $sth ->execute; $numRows = $sth->rows; This should do it. |
|
#3
|
|||
|
|||
|
or you can do:
$result = mysql_db_query(blablah); $num_rows = @mysql_num_rows($result); much easier... |
|
#4
|
|||
|
|||
|
That would be assuming that he's using PHP, from the question, it looks like perl-DBI..
------------------ =Don= |
|
#5
|
|||
|
|||
|
Yes, I'm using Perl DBI. The question I have is, for a search engine w/potential heavy traffic, I understand Perl would be the best solution in terms of speed (?). Does PHP offer any advantages over perl in terms of a search engine?
-thanks www.smartrat.com |
|
#6
|
|||
|
|||
|
Unless you're using mod_perl, php doesn't suffer from the start-up delays that regualr perl does. That can be a significant delay if you're handling many request per second.
Course, mod_perl doesn't suffer from the startup delay either, so go with what you know. (I prefer PHP, but that's just me..) ------------------ =Don= |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Counting # of rows retrieved. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|