Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
SQL::Maker::Plugin::InUserMContributed Perl SQL::Maker::Plugin::InsertMulti(3)

NAME
       SQL::Maker::Plugin::InsertMulti - insert	multiple rows at once on MySQL

SYNOPSIS
	   use SQL::Maker;

	   SQL::Maker->load_plugin('InsertMulti');

	   my $table = 'foo';
	   my @rows = (	+{ bar => 'baz', john => 'man' }, +{ bar => 'bee', john	=> 'row' } );
	   my $builder = SQL::Maker->new( driver => 'mysql' );
	   my ($sql, @binds);
	   ### INSERT INTO `foo` (`bar`, `john`) VALUES	(?, ?),	(?, ?)
	   ( $sql, @binds ) = $builder->insert_multi($table, \@rows);
	   ( $sql, @binds ) = $builder->insert_multi($table, [qw/bar john/], [ map { @$_{qw/bar	john/} } @rows ]);
	   ### INSERT IGNORE `foo` (`bar`, `john`) VALUES (?, ?), (?, ?)
	   ( $sql, @binds ) = $builder->insert_multi($table, [qw/bar john/], [ map { @$_{qw/bar	john/} } @rows ], +{ prefix => 'INSERT IGNORE' });
	   ### INSERT INTO `foo` (`bar`. `john`) VALUES	(?, ?),	(?, ?) ON DUPLICATE KEY	UPDATE `bar` =>	?
	   ( $sql, @binds ) = $builder->insert_multi($table, \@rows, +{	update => +{ bar => 'updated' }	});
	   ( $sql, @binds ) = $builder->insert_multi($table, [qw/bar john/], [ map { @$_{qw/bar	john/} } @rows ], +{ update => +{ bar => 'updated' } });

DESCRIPTION
       This is a plugin	to generate MySQL's INSERT-multi statement.

perl v5.32.1			  2014-12-22SQL::Maker::Plugin::InsertMulti(3)

NAME | SYNOPSIS | DESCRIPTION

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=SQL::Maker::Plugin::InsertMulti&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help