SQL::Functional Cookbook--Updates
2017-04-04
Updates are easy, too.
my ($sql, @sql_params) = UPDATE 'foo', SET(
op( 'bar', '=', 1 ),
op( 'baz', '=', 2 ),
),
WHERE match( 'qux', '=', 3 );
UPDATE
takes a table to update, followed by SET
and WHERE
. In SET
, we’re using the op
function, which is actually an alias for match
. Calling it op
is more readable here, since we’re not matching anything. Note that the data there is still handled as placeholders.
The WHERE
part works just like it does in SELECT
.