nieuws/replies: insert method to add database rows
[minimedit.git] / database.inc.php
index aa864d03df32f5dadedba9441512331f5fe10d5c..6a82507649612a5739bf3fb396062fb1cae2e686 100644 (file)
@@ -18,4 +18,14 @@ class DB
                $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));
+       }
 }