Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am running DB queries for each of those parameters

Somehow I doubt that each of these parameters correspond to columns in different tables. Most likely, you'll only need to update one or two tables for each submit in most circumstances. So instead of updating the database for each parameter1, you could do one or two mass updates2

# 1 # (I don't know which module you're using for your $query->Dump expres +sion, # so I'll simply be using the old school CGI.pm here) use CGI 'param'; use DBI; my $dbh = DBI->connect(...) or die ...; my $id = param 'id'; # Hit the database with an UPDATE for every parameter for my $p (param) { next if $p eq 'id'; my $sql = sprintf("UPDATE mytable SET %s = ? WHERE id = ?", $p) $dbh->do($sql, undef, param($p), $id); }
# 2 # (again, just CGI.pm) use CGI 'param'; use DBI; my $dbh = DBI->connect(...) or die ...; my $id = param 'id'; my %update = map { $_ ne 'id' ? ($_ => param($_)) : () } param; my @bind = (); # First, build one large UDPATE statement # and collect the bind values while we're at it my $sql = "UPDATE mytable SET " . # Doing this from the top + of my head, join(", ", # untested, but it should + get the grep defined, map { # idea across if ($_ ne 'id') { push @bind, param($_); sprintf "%s = ?", $_ } else { undef } } param ) ; # And then hit the database with that UPDATE statement just once. $dbh->do($sql, undef, bind);

In reply to Re: How to get only changed parameter names from CGI script on form submit? by muba
in thread [Solved]: How to get only changed parameter names from CGI script on form submit? by Perl300

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-24 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found