Looked at Q&A for databases at perl.org, been through the Cheetah book 
(several times) and can't seem to find an archive of this list so I'm down 
to asking for help what is probably a FAQ.  But I hope to put a twist on 
it.

I'm querying a table what may return more than one row.  If there is more 
than one row I display a selection list (so the users can pick the one 
they want) or else the results of the query.

So far it is a brute force effort.  I use fetchall_arrayref and determine
the count of rows returned.  Question is is the correct method to return
the count of an array of references 'scalar(@$array_ref)' or is there an
easier/trickier/DBI way to check on the count?


And here's some code.  (Please be gentle.  I'm trying to get back into 
this after several years of hit and miss coding.)

.... 

my ($dbh, $sth, $cnt, $qry_domainname);

....

my $domain_cnt_qry = "SELECT tbl_key, domainname " .
    "  FROM domain_info " .
    " WHERE domain_name LIKE '%?%' " .
    " ORDER BY domainname ";

....

$sth = $dbh->prepare($domain_cnt_qry);
$sth->execute($qry_domainname);

$domain_array = $sth->fetchall_arrayref();
$cnt = scalar(@$domain_array);

if ($cnt > 1) {

        ### Print a selection list of domains

} else {

        ### Print the domain information

}


TIA,
Rod
-- 
  "Open Source Software - Sometimes you get more than you paid for..."


Reply via email to