# Example 1: fetchrow_arrayref my $sth = $db->prepare("SELECT the_name FROM the_table WHERE id=3"); $sth->execute(); print $sth->fetchrow_arrayref()->[0]; $sth->finish(); # Example 2: fetchrow_hashref $sth = $db->prepare("SELECT the_name FROM the_table WHERE id=3"); $sth->execute(); print $sth->fetchrow_hashref()->{'the_name'}; $sth->finish();
I skipped the while{} loop for the fetchrow_hashref() because this is an instance where I know for a fact that there will only be one value returned. My real question is whether or not the value I am retrieving can be put in a variable during the call to prepare() (perhaps replacing it with do()). Something like this perhaps:
my $sth = $db->do("SELECT the_name FROM the_table WHERE id=3"); print $sth;
Thanks ahead of time (assuming you help me) :)
In reply to MySQL and Perl - Shorthand by mt2k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |