NAME
SQL::Maker::Plugin::InsertOnDuplicate - INSERT ... ON DUPLICATE KEY UPDATE
SYNOPSIS
package My::QueryBuilder;
use parent qw/SQL::Maker/;
__PACKAGE__->load_plugin('InsertOnDuplicate');
package main;
my $qb = My::QueryBuilder->new(driver => 'mysql');
$qb->insert_on_duplicate('member', { email => 'foo@exapmle.com', name => $name }, { name => $name });
DESCRIPTION
This is a plugin to generate "INSERT ... ON DUPLICATE KEY UPDATE" query for MySQL.
METHODS
This plugin adds only one method for your query builder class.
- $query_builder->insert_on_duplicate($table_name:Str, $insert_values:HashRef, $update_values:HashRef)
-
Generate "INSERT ... ON DUPLICATE KEY UPDATE ...".
$table_name
is table name to operate.$insert_values
is values to insert.$table_name and $insert_values are passing to
SQL::Maker#insert
$update_values
is SET part for ON DUPLICATE KEY UPDATE. It's processed bySQL::Maker#make_set_clause
.
SEE ALSO
http://dev.mysql.com/doc/refman/5.6/en/insert-on-duplicate.html