September 5th, 2000, 10:19 PM
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.
September 6th, 2000, 12:29 AM
Doesn't $sth->rows work for you?
(From the first page in the DBI::mysql man page)
$dbh = DBI->connect($driver,$user,$database);
$sth = $dbh->prepare("Select * from test");
$numRows = $sth->rows;
This should do it.
September 6th, 2000, 02:13 AM
or you can do:
$result = mysql_db_query(blablah);
$num_rows = @mysql_num_rows($result);
September 6th, 2000, 11:34 AM
That would be assuming that he's using PHP, from the question, it looks like perl-DBI..
September 6th, 2000, 01:55 PM
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?
September 6th, 2000, 06:27 PM
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..)