git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
issue: closed at bottom, option ?open to exclude
[minimedit.git]
/
database.inc.php
diff --git
a/database.inc.php
b/database.inc.php
index aa864d03df32f5dadedba9441512331f5fe10d5c..218335814bebf8e993aeb034449d7dc17efae940 100644
(file)
--- a/
database.inc.php
+++ b/
database.inc.php
@@
-8,7
+8,10
@@
class DB
function __construct($config, $options = [])
{
function __construct($config, $options = [])
{
- $options += [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ];
+ $options += [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
+ ];
$this->dbh = new PDO($config, NULL, NULL, $options);
}
$this->dbh = new PDO($config, NULL, NULL, $options);
}
@@
-18,4
+21,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));
+ }
}
}