diff options
author | Filipp Lepalaan <filipp@mac.com> | 2010-06-27 11:40:53 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2010-06-27 11:40:53 +0300 |
commit | 677d2f066d66a360ebfb367d4521926ad14d5480 (patch) | |
tree | 58887b604a289423d61b925468883a97ef965059 /MainDb.php | |
parent | 63fcc0deec2f821104ea1d16378b392cf1650b6e (diff) | |
download | main-677d2f066d66a360ebfb367d4521926ad14d5480.tar.gz main-677d2f066d66a360ebfb367d4521926ad14d5480.tar.bz2 main-677d2f066d66a360ebfb367d4521926ad14d5480.zip |
some fixes
Diffstat (limited to 'MainDb.php')
-rw-r--r-- | MainDb.php | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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); } |