$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
In reply to Simpler DBI::MySQL queries by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |