#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Piscataway, NJ, USA
    Posts
    10
    Rep 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.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Crestline, CA. USA
    Posts
    9
    Rep 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.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    or you can do:

    $result = mysql_db_query(blablah);

    $num_rows = @mysql_num_rows($result);

    much easier...
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Crestline, CA. USA
    Posts
    9
    Rep Power
    0
    That would be assuming that he's using PHP, from the question, it looks like perl-DBI..

    ------------------
    =Don=
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Piscataway, NJ, USA
    Posts
    10
    Rep 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
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Crestline, CA. USA
    Posts
    9
    Rep 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=

Similar Threads

  1. Replies: 5
    Last Post: January 14th, 2004, 11:41 AM
  2. Counting the number of rows in a table
    By Dekers in forum PHP Development
    Replies: 4
    Last Post: August 11th, 2003, 10:51 AM
  3. Counting the contents of multiple MySQL rows
    By KaiMunk in forum PHP Development
    Replies: 3
    Last Post: May 10th, 2003, 08:40 AM
  4. Counting amount of rows for a field within mysql query
    By strange1 in forum PHP Development
    Replies: 5
    Last Post: December 27th, 2002, 08:24 AM
  5. Problem counting rows
    By bayridge in forum MySQL Help
    Replies: 2
    Last Post: July 23rd, 2002, 08:45 PM

IMN logo majestic logo threadwatch logo seochat tools logo