in reply to Count Number of rows retrieved from SELECT
Update: I'm not sure why this keeps getting downvoted. I know the documentation in DBI says that execute() is only guaranteed to return a true value on success, but a little poking around in DBD::mysql makes me think this is a real feature, if a poorly documented one. I'd be grateful if someone would take the time to explain the --'s.#!perl -l use strict; use warnings; use Data::Dumper; require 'getdbh.pl'; my $dbh = get_dbh(); $dbh->do('USE test'); $dbh->do('CREATE TEMPORARY TABLE t1 (name char(8))'); for (qw/ Jim Judy Steve Jack Jodie Sally Alice /) { $dbh->do('INSERT INTO t1 VALUES (?)', undef, $_); } for (qw/ J S A X /) { my $sth = $dbh->prepare("SELECT name FROM t1 where name like '$_%' +"); my $x = $sth->execute(); print "$_: \$x = $x"; } __END__ J: $x = 4 S: $x = 2 A: $x = 1 X: $x = 0E0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Count Number of rows retrieved from SELECT
by Akhasha (Scribe) on Jun 14, 2005 at 03:22 UTC | |
|
Re^2: Count Number of rows retrieved from SELECT
by monarch (Priest) on Jun 14, 2005 at 02:16 UTC |