SQL::Maker::Plugin::InsertOnDuplicate - INSERT ... ON DUPLICATE KEY UPDATE
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 });
This is a plugin to generate "INSERT ... ON DUPLICATE KEY UPDATE" query for MySQL.
This plugin adds only one method for your query builder class.
Generate "INSERT ... ON DUPLICATE KEY UPDATE ...".
$table_name is table name to operate.
$table_name
$insert_values is values to insert.
$insert_values
$table_name and $insert_values are passing to SQL::Maker#insert
SQL::Maker#insert
$update_values is SET part for ON DUPLICATE KEY UPDATE. It's processed by SQL::Maker#make_set_clause.
$update_values
SQL::Maker#make_set_clause
http://dev.mysql.com/doc/refman/5.6/en/insert-on-duplicate.html
To install SQL::Maker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::Maker
CPAN shell
perl -MCPAN -e shell install SQL::Maker
For more information on module installation, please visit the detailed CPAN module installation guide.