waltw has asked for the wisdom of the Perl Monks concerning the following question:
I am using CGI::App and have as one of my run-modes the following short and simple update routine against a data schema implemented using SQLite.
The objective is to take the edited media type code description returned from an HTML form and update the existing record in the database.
CREATE TABLE Media (media_code TEXT, media_desc TEXT, PRIMARY KEY (media_code));
I'm pulling my hair and beard over this one -- read through Programming the Perl DBI, searched on this site, read through CPAN's docs on CGI and CGI:App.
Thank you,
Walt
sub updateMedia { my $self=shift; my $q = $self->query(); my $dbh = $self->param('mydbh'); my $scripturl = $q->url(); my $scripthome = $q->script_name(); # From HTML form my $media_desc = $q->param('txtMediaDesc'); my $media_code = $q->param('media_code'); # SQL Update my $media_desc_quoted = $dbh->quote( $media_desc ); my $media_code_quoted = $dbh->quote( $media_code ); my $sql = qq{UPDATE Media SET media_desc=$media_desc_quoted WHERE media_code=$media_code_quoted}; my $sth = $dbh->prepare($sql); $sth->execute(); # Redirect back to start $self->header_type('redirect'); $self->header_props(-url=>$scripthome."?rm=editMedia&media_cod +e=".$media_code); return;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Conundrum Using CGI::App
by rhesa (Vicar) on Jul 06, 2006 at 19:59 UTC | |
|
Re: DBI Conundrum Using CGI::App
by waltw (Acolyte) on Jul 06, 2006 at 20:13 UTC | |
|
Re: DBI Conundrum Using CGI::App
by eric256 (Parson) on Jul 06, 2006 at 19:45 UTC | |
by Tanktalus (Canon) on Jul 06, 2006 at 19:50 UTC | |
by eric256 (Parson) on Jul 06, 2006 at 20:46 UTC | |
|
Re: DBI Conundrum Using CGI::App
by Hue-Bond (Priest) on Jul 06, 2006 at 19:32 UTC | |
by waltw (Acolyte) on Jul 06, 2006 at 20:02 UTC | |
by shmem (Chancellor) on Jul 06, 2006 at 19:48 UTC | |
by Hue-Bond (Priest) on Jul 06, 2006 at 20:05 UTC | |
by jZed (Prior) on Jul 06, 2006 at 20:03 UTC |