diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-09-27 10:44:17 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-09-27 10:44:17 +0300 |
commit | e37db3cdbfb1ec57b5126be06325a75ccdc82efe (patch) | |
tree | 29956d8d1d1e60bbcf39edc9b502e3318f395476 /MainDb.php | |
parent | 0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9 (diff) | |
download | main-e37db3cdbfb1ec57b5126be06325a75ccdc82efe.tar.gz main-e37db3cdbfb1ec57b5126be06325a75ccdc82efe.tar.bz2 main-e37db3cdbfb1ec57b5126be06325a75ccdc82efe.zip |
some fixes
Diffstat (limited to 'MainDb.php')
-rw-r--r-- | MainDb.php | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -59,7 +59,8 @@ class MainDb } } - + + self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING); return self::$instance; } @@ -108,25 +109,27 @@ class MainDb $pdo = self::getInstance(); $stmt = $pdo->prepare($sql); - if (!$stmt) { + if( !$stmt ) { list($ec, $dec, $emsg) = $pdo->errorInfo(); $error = $emsg ."\n" . print_r(debug_backtrace(), TRUE); return MainApp::error($error); } - $result = $stmt->execute($data); + $result = $stmt->execute( $data ); - if (!$result) { + if( !$result ) { list($ec, $dec, $emsg) = $pdo->errorInfo(); $error = $emsg ."\n" . print_r(debug_backtrace(), TRUE); return MainApp::error($error); } } - catch (PDOException $e) { - $error = $e->getMessage() . $sql; - $error .= "\n" . print_r(debug_backtrace(), TRUE); - return MainApp::error($error); + catch( PDOException $e ) { + + $error = $e->getMessage() . $sql; + $error .= "\n" . print_r(debug_backtrace(), TRUE); + return MainApp::error( $error ); + } // DELETE statements should report number of rows deleted @@ -149,15 +152,15 @@ class MainDb return $stmt; } - if (empty($data[':id'])) { - $data[':id'] = $pdo->lastInsertId(); + if( empty( $data[':id'] )) { + $data[':id'] = $pdo->lastInsertId('order_id_seq'); } $out = array(); // Always strip ":" prefixes from input array keys - foreach ($data as $k => $v) { - $key = ltrim($k, ':'); + foreach( $data as $k => $v ) { + $key = ltrim( $k, ':' ); $out[$key] = $v; } @@ -185,7 +188,7 @@ class MainDb // count something public static function total($table) { - $sql = 'SELECT COUNT(*) AS the_count FROM `%s`'; + $sql = 'SELECT COUNT(*) AS the_count FROM %s'; $res = self::fetch(sprintf($sql, $table)); $res = current($res); return $res['the_count']; |