migrated update script to PDO database class, refs #1287

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-11-04 11:34:57 +01:00
parent 8638952afe
commit af2c068970
3 changed files with 817 additions and 669 deletions

View File

@@ -48,6 +48,11 @@ class Database {
*/
private static $_dbserver = 0;
/**
* used database-name
*/
private static $_dbname = null;
/**
* Wrapper for PDOStatement::execute so we can catch the PDOException
* and display the error nicely on the panel
@@ -73,6 +78,15 @@ class Database {
return Database::query("SELECT FOUND_ROWS()")->fetchColumn();
}
/**
* returns the database-name which is used
*
* @return string
*/
public static function getDbName() {
return self::$_dbname;
}
/**
* enabled the usage of a root-connection to the database
* Note: must be called *before* any prepare/query/etc.
@@ -89,16 +103,6 @@ class Database {
self::$_needroot = $needroot;
}
/**
* set the database-server (relevant for root-connection)
*
* @param int $dbserver
*/
private static function _setServer($dbserver = 0) {
self::$_dbserver = $dbserver;
self::$_link = null;
}
/**
* let's us interact with the PDO-Object by using static
* call like "Database::function()"
@@ -119,6 +123,16 @@ class Database {
return $result;
}
/**
* set the database-server (relevant for root-connection)
*
* @param int $dbserver
*/
private static function _setServer($dbserver = 0) {
self::$_dbserver = $dbserver;
self::$_link = null;
}
/**
* function that will be called on every static call
* which connects to the database if necessary
@@ -175,6 +189,8 @@ class Database {
'dbname' => $sql["db"]
);
self::$_dbname = $sql["db"];
// add options to dsn-string
foreach ($dbconf["dsn"] as $k => $v) {
$dsn .= $k."=".$v.";";