]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/DBA.php
Issue 10392: Avoid "Friendica can't display this page at the moment"
[friendica.git] / src / Database / DBA.php
index 7dd7ac3e3a4d111d46d90752f2f47f8d664cdb24..097f1b756a19367574c35352029e772d94e654ce 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -183,7 +183,7 @@ class DBA
 
        /**
         * Executes a prepared statement that returns data
-        * Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
+        * Example: $r = p("SELECT * FROM `post` WHERE `guid` = ?", $guid);
         *
         * Please only use it with complicated queries.
         * For all regular queries please use DBA::select or DBA::exists
@@ -290,16 +290,16 @@ class DBA
        /**
         * Insert a row into a table
         *
-        * @param string|array $table               Table name or array [schema => table]
-        * @param array        $param               parameter array
-        * @param bool         $on_duplicate_update Do an update on a duplicate entry
+        * @param string|array $table          Table name or array [schema => table]
+        * @param array        $param          parameter array
+        * @param int          $duplicate_mode What to do on a duplicated entry
         *
         * @return boolean was the insert successful?
         * @throws \Exception
         */
-       public static function insert($table, $param, $on_duplicate_update = false)
+       public static function insert($table, array $param, int $duplicate_mode = Database::INSERT_DEFAULT)
        {
-               return DI::dba()->insert($table, $param, $on_duplicate_update);
+               return DI::dba()->insert($table, $param, $duplicate_mode);
        }
 
        /**
@@ -388,9 +388,6 @@ class DBA
         *
         * @param string|array $table      Table name
         * @param array        $conditions Field condition(s)
-        * @param array        $options
-        *                           - cascade: If true we delete records in other tables that depend on the one we're deleting through
-        *                           relations (default: true)
         *
         * @return boolean was the delete successful?
         * @throws \Exception
@@ -478,7 +475,7 @@ class DBA
         * @return boolean|object
         *
         * Example:
-        * $table = "item";
+        * $table = "post";
         * $fields = array("id", "uri", "uid", "network");
         *
         * $condition = array("uid" => 1, "network" => 'dspr');
@@ -505,7 +502,7 @@ class DBA
         * @return int
         *
         * Example:
-        * $table = "item";
+        * $table = "post";
         *
         * $condition = ["uid" => 1, "network" => 'dspr'];
         * or:
@@ -767,13 +764,27 @@ class DBA
        /**
         * Fills an array with data from a query
         *
-        * @param object $stmt statement object
-        * @param bool   $do_close
+        * @param object $stmt     statement object
+        * @param bool   $do_close Close database connection after last row
+        * @param int    $count    maximum number of rows to be fetched
+        *
         * @return array Data array
         */
-       public static function toArray($stmt, $do_close = true)
+       public static function toArray($stmt, $do_close = true, int $count = 0)
+       {
+               return DI::dba()->toArray($stmt, $do_close, $count);
+       }
+
+       /**
+        * Cast field types according to the table definition
+        *
+        * @param string $table
+        * @param array  $fields
+        * @return array casted fields
+        */
+       public static function castFields(string $table, array $fields)
        {
-               return DI::dba()->toArray($stmt, $do_close);
+               return DI::dba()->castFields($table, $fields);
        }
 
        /**