Commit b85fa0ac authored by Carsten  Rose's avatar Carsten Rose
Browse files

Database.php: Code Cleanup

parent bbc80136
......@@ -524,11 +524,6 @@ const VAR_FILE_DESTINATION = 'fileDestination';
const VAR_SLAVE_ID = ACTION_KEYWORD_SLAVE_ID;
const VAR_FILENAME = 'filename'; // Original filename of an uploaded file.
// PHP class DB can operate in these modes
const MODE_DB_REGULAR = 'regular';
const MODE_DB_NO_LOG = 'noLog';
// PHP class Typeahead
const TYPEAHEAD_API_QUERY = 'query'; // Name of parameter in API call of typeahead.php?query=...&s=... - See also FE_TYPE_AHEAD_SQL
const TYPEAHEAD_API_PREFETCH = 'prefetch'; // Name of parameter in API call of typeahead.php?prefetch=...&s=... - See also FE_TYPE_AHEAD_SQL
......
......@@ -63,23 +63,13 @@ class Database {
* @throws CodeException
* @throws UserFormException
*/
public function __construct($mode = MODE_DB_REGULAR) {
public function __construct() {
$dbInit = '';
switch ($mode) {
case MODE_DB_REGULAR:
$this->store = Store::getInstance();
$config = $this->store->getStore(STORE_SYSTEM);
$this->sqlLog = $this->store->getVar(SYSTEM_SQL_LOG, STORE_SYSTEM);
$dbInit = $this->store->getVar(SYSTEM_DB_INIT, STORE_SYSTEM);
break;
case MODE_DB_NO_LOG:
$configClass = new Config();
$config = $configClass->readConfig();
break;
default:
throw new \qfq\CodeException('Unknown mode: ' . $mode, ERROR_UNKNOWN_MODE);
}
if ($this->mysqli === null) {
$this->mysqli = $this->dbConnect($config);
......@@ -91,7 +81,6 @@ class Database {
}
}
/**
* Open mysqli database connection if not already done.
*
......
......@@ -77,14 +77,14 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
$this->db = new qfq\Database();
}
if (self::$mysqli === null) {
/// Establish additional mysqli access
$dbserver = $this->store->getVar(SYSTEM_DB_SERVER, STORE_SYSTEM);
$dbuser = $this->store->getVar(SYSTEM_DB_USER, STORE_SYSTEM);
$db = $this->store->getVar(SYSTEM_DB_NAME, STORE_SYSTEM);
$dbpw = $this->store->getVar(SYSTEM_DB_PASSWORD, STORE_SYSTEM);
if (self::$mysqli === null) {
self::$mysqli = new \mysqli($dbserver, $dbuser, $dbpw, $db);
if (self::$mysqli->connect_errno) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment