]> git.mxchange.org Git - friendica.git/blobdiff - include/dba.php
Merge remote-tracking branch 'friendica/develop' into develop
[friendica.git] / include / dba.php
index 56cc6c1781e4a38a904776b761b7552c6442174c..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);
 
@@ -109,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
         *
@@ -128,7 +139,7 @@ class dba {
        }
 
        public function q($sql, $onlyquery = false) {
-               global $a;
+               $a = get_app();
 
                if (!$this->db || !$this->connected) {
                        return false;
@@ -397,9 +408,9 @@ function qu($sql) {
                $stmt = @vsprintf($sql,$args); // Disabled warnings
                if ($stmt === false)
                        logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
-               $db->q("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
+               $db->q("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
                $retval = $db->q($stmt);
-               $db->q("COMMIT;");
+               $db->q("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;");
                return $retval;
        }