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
In reply to Re: Module and variable place holders?
by edan
in thread Module and variable place holders?
by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |