Hi All, I have a very peculiar bind_param problem. Below is the (leaned down code snippet) of a routine in a module i'm writing.
Below doesnt work
The bind_param above does not seem to be binding the parameter.sub load { my $class = shift; my $id = shift; my $dbh = Some::Class->get_dbh(); my $sth = $dbh->prepare(<<"ENDSQL"); SELECT field1, field2 FROM table WHERE id = ? ENDSQL my ($field1, $field2); eval { # need to figure out why this bind_param isnt working $sth->bind_param(1, $id); $sth->execute(); $sth->bind_col(1, \$field1); $sth->bind_col(2, \$field2); }; if($@){ print "There was a error"; } $sth->fetch(); $sth->finish(); }
Below does work
If i dont bind the param it works fine. Has anyone experienced this? Is this at the dbi or dbd level.sub load { my $class = shift; my $id = shift; my $dbh = Some::Class->get_dbh(); my $sth = $dbh->prepare(<<"ENDSQL"); SELECT field1, field2 FROM table WHERE id = $id ENDSQL my ($field1, $field2); eval { $sth->execute(); $sth->bind_col(1, \$field1); $sth->bind_col(2, \$field2); }; if($@){ print "There was a error"; } $sth->fetch(); $sth->finish(); }
In reply to DBI bind_param problems by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |