in reply to Module and variable place holders?
You'll be wanting to use placeholders, which are described in further detail in the DBI docs. This gist of it would be the following, in the context of your code:
sub dbh{ my ($statement, $dbh2, @values) = @_; my $sth = $dbh2->prepare($statement) or die "dbh2 = $dbh2 Couldn't + prepare statement: $statement ".$dbh2->errstr; $sth->execute(@values) or die "dbh2 = $dbh2 Couldn't execute state +ment: $statement ".$dbh2->errstr; return $sth; } # ........................ sub insert_lexicon{ my ($self) = @_; $statement = 'INSERT INTO lexicon ( word, meaning, auid) VALUES( ?, ?, ?)'; return ($statement); }
You basically put question-marks in the SQL statement, and pass a list of values to the $dbh->execute() method.
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Module and variable place holders?
by neilwatson (Priest) on Aug 29, 2004 at 15:14 UTC | |
by Tuppence (Pilgrim) on Aug 30, 2004 at 02:20 UTC | |
by tilly (Archbishop) on Aug 30, 2004 at 15:36 UTC |