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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -24,7 +24,6 @@
* @return string The corrected dirname * @return string The corrected dirname
* @author Florian Lippert <flo@syscp.org> * @author Florian Lippert <flo@syscp.org>
*/ */
function makeCorrectDir($dir) { function makeCorrectDir($dir) {
$dir = trim($dir); $dir = trim($dir);