Proposed Name Space DBIx::CopyRecords

Proposed Name Space DBIx::CopyRecords

am 31.12.2006 20:18:28 von jck000

This is a request for comments and opinions concerning a module I have
recently developed.

The module is designed to copy a set of related records in as many
tables as you specify. It's useful if you have a system where you need
several generations of the same records. For example, in a company at
which I worked, we made copies of credit report data and allowed the
user to edit the newest copy. This module would be useful for that.

use CopyRecords;

# connect
my $dbh = DBI->connect('dbi:MySQL:','login','password');
my $CR = DBIx::CopyRecords->new($dbh);

$CR->copyrecords(
{ table_name => 'invoice',
primary_key => 'invoice_number',
primary_key_value => 'nextvalue',
child => [ { table_name => products,
primary_key => line_item_id,
primary_key_value => NULL,
foreign_key => invoice_number },
{ table_name => services,
primary_key => line_item_id,
primary_key_value => NULL,
foreign_key => invoice_number } ]
});

# disconnect database
$dbh->disconnect;


Thanks.

Jack