neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
Calling module (Mason component):
<%args> $action => '' </%args> <%perl> use strict; use warnings; use lib "/home/httpd/starfrontiers/modules"; use SQLlib; use DBI; # is user logged in? If so, get user id my $auid = $m->comp('auth.mas'); my $dbh2 = $m->comp('dbh2.mas'); # get statement defined from form my $sql = SQLlib->new; my $statement = $sql->$action(); #print "statement = ".$statement; dbh($statement, $dbh2); $m->redirect("/wiki/access_granted.html"); $m->auto_send_headers(0); $m->clear_buffer; $m->abort; sub dbh{ my ($statement, $dbh2) = @_; my $sth = $dbh2->prepare($statement) or die "dbh2 = $dbh2 Couldn't + prepare statement: $statement ".$dbh2->errstr; $sth->execute or die "dbh2 = $dbh2 Couldn't execute statement: $st +atement ".$dbh2->errstr; return $sth; } </%perl>
Module snippet
sub insert_lexicon{ my ($self) = @_; $statement = 'INSERT INTO lexicon ( word, meaning, auid) VALUES( \'$word\', \'$meaning\', \'$auid\');'; return ($statement); }
The statement has variables that are passed to the component. Currenlty the insert statement works but, the string "$word" and "$meaning" are literally inserted. In the module I need the variables to be literal strings but, once returned to the component I need the variables to be their actual values. Does that make sense? Is there a better way?
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module and variable place holders?
by edan (Curate) on Aug 29, 2004 at 15:00 UTC | |
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 | |
|
Re: Module and variable place holders?
by PodMaster (Abbot) on Aug 29, 2004 at 15:02 UTC |