"dba" is now a static class

This commit is contained in:
Michael 2017-10-11 12:56:36 +00:00
parent dbcd1d1ae3
commit a29b7e7153
14 changed files with 203 additions and 341 deletions

View file

@ -606,10 +606,9 @@ function admin_page_queue(App $a) {
* @return string
*/
function admin_page_summary(App $a) {
global $db;
// are there MyISAM tables in the DB? If so, trigger a warning message
$r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1",
dbesc($db->database_name()));
dbesc(dba::database_name()));
$showwarning = false;
$warningtext = array();
if (dbm::is_result($r)) {
@ -726,7 +725,7 @@ function admin_page_site_post(App $a) {
$old_host = str_replace("http://", "@", normalise_link($old_url));
function update_table($table_name, $fields, $old_url, $new_url) {
global $db, $a;
global $a;
$dbold = dbesc($old_url);
$dbnew = dbesc($new_url);
@ -743,7 +742,7 @@ function admin_page_site_post(App $a) {
$q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
$r = q($q);
if (!$r) {
notice("Failed updating '$table_name': ".$db->error);
notice("Failed updating '$table_name': ".dba::errorMessage());
goaway('admin/site');
}
}

View file

@ -24,8 +24,6 @@ function directory_post(App $a) {
}
function directory_content(App $a) {
global $db;
require_once("mod/proxy.php");
if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||

View file

@ -28,7 +28,7 @@ function install_init(App $a) {
}
function install_post(App $a) {
global $install_wizard_pass, $db;
global $install_wizard_pass;
switch($install_wizard_pass) {
case 1:
@ -44,9 +44,7 @@ function install_post(App $a) {
$phpath = notags(trim($_POST['phpath']));
require_once("include/dba.php");
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
if (!$db->connected) {
if (!dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true)) {
$a->data['db_conn_failed'] = true;
}
@ -65,7 +63,7 @@ function install_post(App $a) {
$rino = 2;
// connect to db
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true);
$tpl = get_markup_template('htconfig.tpl');
$txt = replace_macros($tpl,array(
@ -87,7 +85,7 @@ function install_post(App $a) {
$a->data['txt'] = $txt;
}
$errors = load_database($db);
$errors = load_database();
if ($errors) {
@ -103,7 +101,7 @@ function install_post(App $a) {
function install_content(App $a) {
global $install_wizard_pass, $db;
global $install_wizard_pass;
$o = '';
$wizard_status = "";
$install_title = t('Friendica Communications Server - Setup');
@ -133,7 +131,7 @@ function install_content(App $a) {
$db_return_text .= $txt;
}
if ($db && $db->connected) {
if (dba::$connected) {
$r = q("SELECT COUNT(*) as `total` FROM `user`");
if (dbm::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl');
@ -534,7 +532,7 @@ function load_database_rem($v, $i) {
}
}
function load_database($db) {
function load_database() {
require_once("include/dbstructure.php");
$errors = update_structure(false, true);