Using DBI however, I can't see a way to get my total returned rows count without doing a seperate COUNT(*) query beforehand and then repeating the same query in a non-grouping fashion. For instance... a chunk of code from a script I'm working on:
I look forward to your input.## chunk 'O' code $sql = "SELECT COUNT(*) "; $sql .= "FROM sc_products "; $sql .= "WHERE name LIKE '%$search_name%' "; $sql .= "AND keywords LIKE '%Color%'"; $sth = $dbh->prepare($sql); $sth->execute || $error->LogError("Error opening database connection f +or product count in search.cgi".$dbh->errstr, 0); # get my count my $count = $sth->fetchrow_array; $sth->finish; $sql = "SELECT name, image2 "; $sql .= "FROM sc_products "; $sql .= "WHERE name LIKE '%$search_name%' "; $sql .= "AND keywords LIKE '%Color%'"; $sth = $dbh->prepare($sql); $sth->execute || $error->LogError("Error opening database connection f +or product count in search.cgi".$dbh->errstr, 0); while(my @results = $sth->fetchrow_array) { ## Use my count in here for some cool table formatting... print "<tr><td class=\"imgs\">... } $sth->finish; $dbh->disconnect();
In reply to DBI, From PHP to Perl by dstefani
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |