Name
sqlUpdate — updates rows in the database
Synopsis
my $rows = $slashdb->sqlUpdate($table, $data, $where);
sqlUpdate
constructs and executes a SQL statement to
update existing rows in a database table. It returns the number of updated
rows. Most existing functions ignore the value, but it can be used to check
the success or failure of the operation. The $table
parameter is a string containing the name of the table or a comma-separated
list of tables to update. $data
must be a reference to a
hash associating column names with the field values. The values will
automatically be passed through sqlQuote
unless the key
starts with a single dash. The $where
parameter is
required and is used to add a WHERE
clause to the statement. (The function
automatically prepends WHERE
to the value of
$where
.)
Example
# sig must be quoted, fakeemail probably should be my %values = ( karma => -10, -sig => 'Love,<br />Edwin "Snarky Boy" Redford', -fakeemail => 'snark@tired-rant.com', ); my $rows = $slashdb->sqlUpdate('users', \%values, "uid=$uid"); print "Updated okay!\n" if $rows;
Get Running Weblogs with Slash now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.