MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 5th, 2000, 09:19 PM
gustavopeco gustavopeco is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Piscataway, NJ, USA
Posts: 10 gustavopeco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old September 5th, 2000, 11:29 PM
Cougar Cougar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Crestline, CA. USA
Posts: 9 Cougar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old September 6th, 2000, 01:13 AM
rpgswap.com rpgswap.com is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 51 rpgswap.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
or you can do:

$result = mysql_db_query(blablah);

$num_rows = @mysql_num_rows($result);

much easier...

Reply With Quote
  #4  
Old September 6th, 2000, 10:34 AM
Cougar Cougar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Crestline, CA. USA
Posts: 9 Cougar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That would be assuming that he's using PHP, from the question, it looks like perl-DBI..

------------------
=Don=

Reply With Quote
  #5  
Old September 6th, 2000, 12:55 PM
gustavopeco gustavopeco is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Piscataway, NJ, USA
Posts: 10 gustavopeco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #6  
Old September 6th, 2000, 05:27 PM
Cougar Cougar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Crestline, CA. USA
Posts: 9 Cougar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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=

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Counting # of rows retrieved.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT