aboutsummaryrefslogtreecommitdiffstats
path: root/MainDb.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-05-22 16:14:58 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-05-22 16:14:58 +0300
commit63fcc0deec2f821104ea1d16378b392cf1650b6e (patch)
tree98b1eac20cb572729aa8877b7b369ddc467106c5 /MainDb.php
parentbf1475c7d5a78759e0819f3934f5deb90f478fa2 (diff)
downloadmain-63fcc0deec2f821104ea1d16378b392cf1650b6e.tar.gz
main-63fcc0deec2f821104ea1d16378b392cf1650b6e.tar.bz2
main-63fcc0deec2f821104ea1d16378b392cf1650b6e.zip
More fixes, better PHP 5.3 support
Diffstat (limited to 'MainDb.php')
-rw-r--r--MainDb.php40
1 files changed, 18 insertions, 22 deletions
diff --git a/MainDb.php b/MainDb.php
index 0922cdf..89006ed 100644
--- a/MainDb.php
+++ b/MainDb.php
@@ -12,12 +12,11 @@ class MainDb
}
- /**
- * Open persistent connection to database
- */
+ ////
+ // open persistent connection to database
public static function getInstance()
{
- $c = App::conf();
+ $c = MainApp::conf();
if (!self::$instance)
{
@@ -27,10 +26,11 @@ class MainDb
$c['db.username'], $c['db.password'], array(PDO::ATTR_PERSISTENT => true)
);
- self::$instance->query("SET NAMES utf8");
+ // always use UTF-8?
+ self::$instance->query('SET NAMES utf8');
} catch (PDOException $e) {
- exit(App::error($e->getMessage()));
+ exit(MainApp::error($e->getMessage()));
}
}
@@ -39,25 +39,23 @@ class MainDb
}
- /**
- * Deny cloning
- */
+ ////
+ // deny cloning
public function __clone()
{
- trigger_error("Cloning not work is", E_USER_ERROR);
+ trigger_error('Cloning disabled', E_USER_ERROR);
}
- /**
- * Execute an SQL query
- * @return mixed
- */
+ ////
+ // execute an SQL query
+ // @return mixed
public static function query($sql, $data = null)
{
if (!$data) {
$data = array();
}
- // Might be just a string
+ // might be just a string
if (!is_array($data)) {
$data = array($data);
}
@@ -71,13 +69,13 @@ class MainDb
if (!$result) {
list($ec, $dec, $emsg) = $pdo->errorInfo();
$error = $emsg ."\n" . print_r(debug_backtrace(), true);
- return App::error($error);
+ return MainApp::error($error);
}
} catch (PDOException $e) {
$error = $e->getMessage() . $sql;
$error .= "\n" . print_r(debug_backtrace(), true);
- return App::error($error);
+ return MainApp::error($error);
}
// Select statements need the query results
@@ -101,13 +99,11 @@ class MainDb
}
- /**
- *
- */
+ ////
+ // fetch something from DB
public static function fetch($sql, $data = null)
{
- $stmt = self::query($sql, $data)
- or exit(App::error("Error executing query $sql"));
+ $stmt = self::query($sql, $data) or exit(MainApp::error("Error executing query $sql"));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}