git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nieuws/replies: insert method to add database rows
[minimedit.git]
/
database.inc.php
diff --git
a/database.inc.php
b/database.inc.php
index aa864d03df32f5dadedba9441512331f5fe10d5c..6a82507649612a5739bf3fb396062fb1cae2e686 100644
(file)
--- a/
database.inc.php
+++ b/
database.inc.php
@@
-18,4
+18,14
@@
class DB
$stmt->execute($params);
return $stmt;
}
$stmt->execute($params);
return $stmt;
}
+
+ function insert($table, $row)
+ {
+ $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)',
+ '"'.$table.'"',
+ implode(', ', array_keys($row)),
+ implode(', ', array_fill(0, count($row), '?'))
+ );
+ return $this->query($sql, array_values($row));
+ }
}
}