Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
$sth = $dbh->prepare( "something" ) || die "Error: " . $dbh->errstr; $sth->execute() while ( my $ref = $sth->fetchrow_hashref() ) { print "$ref->{something}"; } }
But that's a lot of code to get a single value that I know is there.
I know, because I've asked this question before on the Chatterbox, (sorry about any déjà vu!) that there's a way to do something like this
$single_scalar = $sth->something();
It's not a major issue, it's just that when I just want to get something really simple, like the first name of a person whose ID is '1', and I know they exist, I still end up doing that whole hashref thing, which is overkill.
As I say, I know I've asked this before, and forgotten the answer, but I also don't know where to look in the documentation to find answers like this. So it's a "teach a man to fish" thing. Tell me where I should be looking up this kind of thing and I promise not to ask again.
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simpler DBI::MySQL queries
by davido (Cardinal) on Dec 01, 2004 at 06:51 UTC | |
|
Re: Simpler DBI::MySQL queries
by edan (Curate) on Dec 01, 2004 at 06:53 UTC | |
|
Re: Simpler DBI::MySQL queries
by b10m (Vicar) on Dec 01, 2004 at 08:33 UTC | |
|
Re: Simpler DBI::MySQL queries
by bart (Canon) on Dec 01, 2004 at 11:07 UTC | |
by Juerd (Abbot) on Dec 18, 2004 at 12:41 UTC | |
|
Re: Simpler DBI::MySQL queries
by jZed (Prior) on Dec 01, 2004 at 18:17 UTC | |
by Cody Pendant (Prior) on Dec 02, 2004 at 00:44 UTC | |
by Anonymous Monk on Dec 02, 2004 at 04:58 UTC | |
|
Re: Simpler DBI::MySQL queries
by dragonchild (Archbishop) on Dec 01, 2004 at 13:24 UTC | |
|
Re: Simpler DBI::MySQL queries
by Anonymous Monk on Dec 01, 2004 at 09:26 UTC | |
by Mutant (Priest) on Dec 01, 2004 at 10:00 UTC |