aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2004-11-16 23:38:34 +0000
committerplegall <plg@piwigo.org>2004-11-16 23:38:34 +0000
commit1bf3753f1449eedc4bd39c79b6ca17dc4f396e76 (patch)
tree7d7443b94356cd18a038b3f104f6e21a35d01279 /admin/include/functions.php
parent973e0f8806cd6d569c01977ad5112e16cc7a7f6f (diff)
- images.path column added to reduce database access
- function mass_inserts moved from admin/remote_sites.php to admin/include/function.php - function mass_inserts used in admin/update.php git-svn-id: http://piwigo.org/svn/trunk@606 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 54ec9d8b2..63f59471b 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -784,4 +784,51 @@ function my_error($header, $echo = true)
return $error;
}
}
+
+/**
+ * inserts multiple lines in a table
+ *
+ * @param string table_name
+ * @param array dbields
+ * @param array inserts
+ * @return void
+ */
+function mass_inserts($table_name, $dbfields, $inserts)
+{
+ // inserts all found categories
+ $query = '
+INSERT INTO '.$table_name.'
+ ('.implode(',', $dbfields).')
+ VALUES';
+ foreach ($inserts as $insert_id => $insert)
+ {
+ $query.= '
+ ';
+ if ($insert_id > 0)
+ {
+ $query.= ',';
+ }
+ $query.= '(';
+ foreach ($dbfields as $field_id => $dbfield)
+ {
+ if ($field_id > 0)
+ {
+ $query.= ',';
+ }
+
+ if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
+ {
+ $query.= 'NULL';
+ }
+ else
+ {
+ $query.= "'".$insert[$dbfield]."'";
+ }
+ }
+ $query.=')';
+ }
+ $query.= '
+;';
+ pwg_query($query);
+}
?>