Skip to content
Snippets Groups Projects
Commit a6a094ab authored by Marius Cramer's avatar Marius Cramer
Browse files

- added function to insert db data from array

parent 5a0b54cd
No related branches found
No related tags found
No related merge requests found
...@@ -538,7 +538,27 @@ class db extends mysqli ...@@ -538,7 +538,27 @@ class db extends mysqli
} }
return $out; return $out;
} }
public function insertFromArray($tablename, $data) {
if(!is_array($data)) return false;
$k_query = '';
$v_query = '';
$params = array($tablename);
$v_params = array();
foreach($data as $key => $value) {
$k_query .= ($k_query != '' ? ', ' : '') . '??';
$v_query .= ($v_query != '' ? ', ' : '') . '?';
$params[] = $key;
$v_params[] = $value;
}
$query = 'INSERT INTO ?? (' . $k_query . ') VALUES (' . $v_query . ')';
return $this->query($query, true, $params + $v_params);
}
public function diffrec($record_old, $record_new) { public function diffrec($record_old, $record_new) {
$diffrec_full = array(); $diffrec_full = array();
$diff_num = 0; $diff_num = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment