]> git.mxchange.org Git - friendica.git/blobdiff - include/dba.php
Merge branch 'develop' into rewrites/dbm_is_result
[friendica.git] / include / dba.php
index 7ca520712a455a31d53d4b92e24800cbcbdac124..920027cbcfaeef721a02f2ec3214efed0fcf459b 100644 (file)
@@ -35,7 +35,7 @@ class dba {
        public  $error = false;
 
        function __construct($server, $user, $pass, $db, $install = false) {
-               global $a;
+               $a = get_app();
 
                $stamp1 = microtime(true);
 
@@ -65,7 +65,6 @@ class dba {
                        $this->db = @new mysqli($server,$user,$pass,$db);
                        if (! mysqli_connect_errno()) {
                                $this->connected = true;
-                               //mysqli_set_charset($this->db, 'utf8');
                        }
                        if (isset($a->config["system"]["db_charset"])) {
                                $this->db->set_charset($a->config["system"]["db_charset"]);
@@ -75,7 +74,6 @@ class dba {
                        $this->db = mysql_connect($server,$user,$pass);
                        if ($this->db && mysql_select_db($db,$this->db)) {
                                $this->connected = true;
-                               //mysql_set_charset('utf8', $this->db);
                        }
                        if (isset($a->config["system"]["db_charset"]))
                                mysql_set_charset($a->config["system"]["db_charset"], $this->db);
@@ -111,6 +109,17 @@ class dba {
                return $return;
        }
 
+       /**
+        * @brief Returns the selected database name
+        *
+        * @return string
+        */
+       public function database_name() {
+               $r = $this->q("SELECT DATABASE() AS `db`");
+
+               return $r[0]['db'];
+       }
+
        /**
         * @brief Returns the number of rows
         *
@@ -130,7 +139,7 @@ class dba {
        }
 
        public function q($sql, $onlyquery = false) {
-               global $a;
+               $a = get_app();
 
                if (!$this->db || !$this->connected) {
                        return false;