version 1.22, 2004/07/21 21:14:36
|
version 1.23, 2004/07/26 19:36:21
|
Line 901 sub store_row {
|
Line 901 sub store_row {
|
return 1; |
return 1; |
} |
} |
|
|
|
|
|
############################### |
|
|
|
=pod |
|
|
|
=item &bulk_store_rows() |
|
|
|
Inputs: table id, [columns],[[row data1].[row data2],...] |
|
|
|
returns undef on error, 1 on success. |
|
|
|
=cut |
|
|
|
############################### |
|
sub bulk_store_rows { |
|
my ($table_id,$columns,$rows) = @_; |
|
# |
|
return undef if (! defined(&connect_to_db())); |
|
my $dbh = &get_dbh(); |
|
return undef if (! defined($dbh)); |
|
my $table_status = &check_table($table_id); |
|
return undef if (! defined($table_status)); |
|
if (! $table_status) { |
|
$errorstring = "table $table_id does not exist."; |
|
return undef; |
|
} |
|
# |
|
my $tablename = &translate_id($table_id); |
|
# |
|
my $request = 'INSERT IGNORE INTO '.$tablename.' '; |
|
if (defined($columns) && ref($columns) eq 'ARRAY') { |
|
$request .= join(',',@$columns).' '; |
|
} |
|
if (! defined($rows) || ref($rows) ne 'ARRAY') { |
|
$errorstring = "no input rows given."; |
|
return undef; |
|
} |
|
$request .= 'VALUES '; |
|
foreach my $row (@$rows) { |
|
# avoid doing row stuff here... |
|
$request .= '('.join(',',@$row).'),'; |
|
} |
|
$request =~ s/,$//; |
|
$dbh->do($request); |
|
if ($dbh->err) { |
|
$errorstring = 'Attempted '.$/.$request.$/.'Got error '.$dbh->errstr(); |
|
return undef; |
|
} |
|
return 1; |
|
} |
|
|
|
|
############################### |
############################### |
|
|
=pod |
=pod |