Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: More DBI Problems!!!

by repson (Chaplain)
on Apr 23, 2001 at 14:47 UTC ( #74677=note: print w/ replies, xml ) Need Help??


in reply to More DBI Problems!!!

It would help if you told us which line 50 was in the future.

However, I think the problem is in
$dbh->selectrow_array($query)

The method selectrow_array is for performing a full prepare, execute and returning the array. The parameter is an sql string, not a query object.

What you probably meant was:
$query->fetchrow_array

Which returns a single row of the prepared and executed query it is call on.


Comment on Re: More DBI Problems!!!
Select or Download Code
Re: Re: More DBI Problems!!!
by chipmunk (Parson) on Apr 24, 2001 at 08:00 UTC
    I think repson must be right that you meant to use $query->fetchrow_array instead of $dbh->selectrow_array($query).

    However, the $dbh->select... methods can take an already prepared statement handle as the first argument. This allows you to prepare the statement once ahead of time, and then execute it with select... many times. For example:

    my $sth = $dbh->prepare(<<EndOfSQL); SELECT name FROM item WHERE id = ? EndOfSQL while (<>) { chomp; if (($name) = $dbh->selectrow_array($sth, {}, $_)) { print "$_ => $name\n"; } else { print "$_ not found\n"; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://74677]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2014-07-25 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls