in reply to MySQL and Perl - Shorthand

What you want is:

my ($the_name) = $dbh->selectrow_array( "SELECT the_name FROM the_table WHERE id=3");
but if you ever want to know another id, you're better off with:
$sth = $db->prepare("SELECT the_name FROM the_table WHERE id=?"); $sth->execute(3); my ($the_name) = $sth->fetchrow_array;

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: MySQL and Perl - Shorthand
by broquaint (Abbot) on Sep 21, 2002 at 13:06 UTC
    This
    $sth = $db->prepare("SELECT the_name FROM the_table WHERE id=?"); $sth->execute(3); my ($the_name) = $sth->fetchrow_array;
    Can be converted into this
    my ($the_name) = $dbh->selectrow_array(<<SQL, undef, 3); SELECT the_name FROM the_table WHERE id = ? SQL
    Although it always feels a little weird using selectrow_array for a single value. But I guess that's what abstraction layers are for :)
    HTH

    _________
    broquaint