]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/DBA.php
Merge pull request #9500 from MrPetovan/bug/9326-owner-view-blocked
[friendica.git] / src / Database / DBA.php
index 46bd871b4a748838beeaf04f706b204f6369f6b2..7dd7ac3e3a4d111d46d90752f2f47f8d664cdb24 100644 (file)
@@ -72,6 +72,16 @@ class DBA
                return DI::dba()->getConnection();
        }
 
+       /**
+        * Return the database driver string
+        *
+        * @return string with either "pdo" or "mysqli"
+        */
+       public static function getDriver()
+       {
+               return DI::dba()->getDriver();
+       }
+
        /**
         * Returns the MySQL server version string
         *
@@ -292,6 +302,21 @@ class DBA
                return DI::dba()->insert($table, $param, $on_duplicate_update);
        }
 
+       /**
+        * Inserts a row with the provided data in the provided table.
+        * If the data corresponds to an existing row through a UNIQUE or PRIMARY index constraints, it updates the row instead.
+        *
+        * @param string|array $table Table name or array [schema => table]
+        * @param array        $param parameter array
+        *
+        * @return boolean was the insert successful?
+        * @throws \Exception
+        */
+       public static function replace($table, $param)
+       {
+               return DI::dba()->replace($table, $param);
+       }
+
        /**
         * Fetch the id of the last insert command
         *
@@ -654,10 +679,18 @@ class DBA
         */
        public static function mergeConditions(array ...$conditions)
        {
+               if (count($conditions) == 1) {
+                       return current($conditions);
+               }
+
                $conditionStrings = [];
                $result = [];
 
                foreach ($conditions as $key => $condition) {
+                       if (!$condition) {
+                               continue;
+                       }
+
                        $condition = self::collapseCondition($condition);
 
                        $conditionStrings[] = array_shift($condition);