aboutsummaryrefslogtreecommitdiffstats
path: root/MainDb.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-06-27 11:40:53 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-06-27 11:40:53 +0300
commit677d2f066d66a360ebfb367d4521926ad14d5480 (patch)
tree58887b604a289423d61b925468883a97ef965059 /MainDb.php
parent63fcc0deec2f821104ea1d16378b392cf1650b6e (diff)
downloadmain-677d2f066d66a360ebfb367d4521926ad14d5480.tar.gz
main-677d2f066d66a360ebfb367d4521926ad14d5480.tar.bz2
main-677d2f066d66a360ebfb367d4521926ad14d5480.zip
some fixes
Diffstat (limited to 'MainDb.php')
-rw-r--r--MainDb.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/MainDb.php b/MainDb.php
index 89006ed..e672651 100644
--- a/MainDb.php
+++ b/MainDb.php
@@ -54,7 +54,7 @@ class MainDb
if (!$data) {
$data = array();
}
-
+
// might be just a string
if (!is_array($data)) {
$data = array($data);
@@ -78,13 +78,18 @@ class MainDb
return MainApp::error($error);
}
- // Select statements need the query results
+ // select statements need the query results
if (preg_match('/^SELECT/i', $sql)) {
return $stmt;
}
- if (empty($data['id'])) {
- $data['id'] = $pdo->lastInsertId();
+ // describe statements need the query results
+ if (preg_match('/^DESCRIBE/i', $sql)) {
+ return $stmt;
+ }
+
+ if (empty($data[':id'])) {
+ $data[':id'] = $pdo->lastInsertId();
}
$out = array();
@@ -103,7 +108,8 @@ class MainDb
// fetch something from DB
public static function fetch($sql, $data = null)
{
- $stmt = self::query($sql, $data) or exit(MainApp::error("Error executing query $sql"));
+ $stmt = self::query($sql, $data)
+ or exit(MainApp::error('Error executing query '.$sql));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}