]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/Database.php
Remove deprecated code
[friendica.git] / src / Database / Database.php
index 7d3d7fae7e02ad846868876404ebf5f6ca992420..14e186a72f63a4cbf94d31869da5b81e2f5d52eb 100644 (file)
@@ -2,14 +2,14 @@
 
 namespace Friendica\Database;
 
-use Friendica\Core\Config\Cache\IConfigCache;
+use Friendica\Core\Config\Cache;
 use Friendica\Core\System;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Profiler;
 use mysqli;
 use mysqli_result;
 use mysqli_stmt;
-use ParagonIE\HiddenString\HiddenString;
 use PDO;
 use PDOException;
 use PDOStatement;
@@ -22,76 +22,92 @@ use Psr\Log\LoggerInterface;
  */
 class Database
 {
-       private $connected = false;
+       protected $connected = false;
 
        /**
-        * @var IConfigCache
+        * @var Cache
         */
-       private $configCache;
+       protected $configCache;
        /**
         * @var Profiler
         */
-       private $profiler;
+       protected $profiler;
        /**
         * @var LoggerInterface
         */
-       private $logger;
-       private $server_info    = '';
-       private $connection;
-       private $driver;
+       protected $logger;
+       protected $server_info    = '';
+       /** @var PDO|mysqli */
+       protected $connection;
+       protected $driver;
        private $error          = false;
        private $errorno        = 0;
        private $affected_rows  = 0;
-       private $in_transaction = false;
-       private $in_retrial     = false;
+       protected $in_transaction = false;
+       protected $in_retrial     = false;
        private $relation       = [];
-       private $db_serveraddr;
-       private $db_user;
-       /**
-        * @var HiddenString
-        */
-       private $db_pass;
-       private $db_name;
-       private $db_charset;
 
-       public function __construct(IConfigCache $configCache, Profiler $profiler, LoggerInterface $logger, $serveraddr, $user, HiddenString $pass, $db, $charset = null)
+       public function __construct(Cache $configCache, Profiler $profiler, LoggerInterface $logger, array $server = [])
        {
                // We are storing these values for being able to perform a reconnect
                $this->configCache   = $configCache;
                $this->profiler      = $profiler;
                $this->logger        = $logger;
-               $this->db_serveraddr = $serveraddr;
-               $this->db_user       = $user;
-               $this->db_pass       = $pass;
-               $this->db_name       = $db;
-               $this->db_charset    = $charset;
 
+               $this->readServerVariables($server);
                $this->connect();
 
-               DBA::init($this);
+               if ($this->isConnected()) {
+                       // Loads DB_UPDATE_VERSION constant
+                       DBStructure::definition($configCache->get('system', 'basepath'), false);
+               }
+       }
+
+       private function readServerVariables(array $server)
+       {
+               // Use environment variables for mysql if they are set beforehand
+               if (!empty($server['MYSQL_HOST'])
+                   && (!empty($server['MYSQL_USERNAME'] || !empty($server['MYSQL_USER'])))
+                   && $server['MYSQL_PASSWORD'] !== false
+                   && !empty($server['MYSQL_DATABASE']))
+               {
+                       $db_host = $server['MYSQL_HOST'];
+                       if (!empty($server['MYSQL_PORT'])) {
+                               $db_host .= ':' . $server['MYSQL_PORT'];
+                       }
+                       $this->configCache->set('database', 'hostname', $db_host);
+                       unset($db_host);
+                       if (!empty($server['MYSQL_USERNAME'])) {
+                               $this->configCache->set('database', 'username', $server['MYSQL_USERNAME']);
+                       } else {
+                               $this->configCache->set('database', 'username', $server['MYSQL_USER']);
+                       }
+                       $this->configCache->set('database', 'password', (string) $server['MYSQL_PASSWORD']);
+                       $this->configCache->set('database', 'database', $server['MYSQL_DATABASE']);
+               }
        }
 
        public function connect()
        {
                if (!is_null($this->connection) && $this->connected()) {
-                       return true;
+                       return $this->connected;
                }
 
-               $port       = 0;
-               $serveraddr = trim($this->db_serveraddr);
+               // Reset connected state
+               $this->connected = false;
 
+               $port       = 0;
+               $serveraddr = trim($this->configCache->get('database', 'hostname'));
                $serverdata = explode(':', $serveraddr);
                $server     = $serverdata[0];
-
                if (count($serverdata) > 1) {
                        $port = trim($serverdata[1]);
                }
-
                $server  = trim($server);
-               $user    = trim($this->db_user);
-               $pass    = trim($this->db_pass);
-               $db      = trim($this->db_name);
-               $charset = trim($this->db_charset);
+               $user    = trim($this->configCache->get('database', 'username'));
+               $pass    = trim($this->configCache->get('database', 'password'));
+               $db      = trim($this->configCache->get('database', 'database'));
+               $charset = trim($this->configCache->get('database', 'charset'));
 
                if (!(strlen($server) && strlen($user))) {
                        return false;
@@ -114,7 +130,7 @@ class Database
                                $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                                $this->connected = true;
                        } catch (PDOException $e) {
-                               /// @TODO At least log exception, don't ignore it!
+                               $this->connected = false;
                        }
                }
 
@@ -160,24 +176,34 @@ class Database
                $this->logger = $logger;
        }
 
+       /**
+        * Sets the profiler for DBA
+        *
+        * @param Profiler $profiler
+        */
+       public function setProfiler(Profiler $profiler)
+       {
+               $this->profiler = $profiler;
+       }
        /**
         * Disconnects the current database connection
         */
        public function disconnect()
        {
-               if (is_null($this->connection)) {
-                       return;
+               if (!is_null($this->connection)) {
+                       switch ($this->driver) {
+                               case 'pdo':
+                                       $this->connection = null;
+                                       break;
+                               case 'mysqli':
+                                       $this->connection->close();
+                                       $this->connection = null;
+                                       break;
+                       }
                }
 
-               switch ($this->driver) {
-                       case 'pdo':
-                               $this->connection = null;
-                               break;
-                       case 'mysqli':
-                               $this->connection->close();
-                               $this->connection = null;
-                               break;
-               }
+               $this->driver    = null;
+               $this->connected = false;
        }
 
        /**
@@ -200,7 +226,7 @@ class Database
        }
 
        /**
-        * @brief Returns the MySQL server version string
+        * Returns the MySQL server version string
         *
         * This function discriminate between the deprecated mysql API and the current
         * object-oriented mysqli API. Example of returned string: 5.5.46-0+deb8u1
@@ -223,7 +249,7 @@ class Database
        }
 
        /**
-        * @brief Returns the selected database name
+        * Returns the selected database name
         *
         * @return string
         * @throws \Exception
@@ -236,7 +262,7 @@ class Database
        }
 
        /**
-        * @brief Analyze a database query and log this if some conditions are met.
+        * Analyze a database query and log this if some conditions are met.
         *
         * @param string $query The database query that will be analyzed
         *
@@ -322,6 +348,11 @@ class Database
                }
        }
 
+       public function isConnected()
+       {
+               return $this->connected;
+       }
+
        public function connected()
        {
                $connected = false;
@@ -342,12 +373,13 @@ class Database
                                $connected = $this->connection->ping();
                                break;
                }
+
                return $connected;
        }
 
        /**
-        * @brief Replaces ANY_VALUE() function by MIN() function,
-        *  if the database server does not support ANY_VALUE().
+        * Replaces ANY_VALUE() function by MIN() function,
+        * if the database server does not support ANY_VALUE().
         *
         * Considerations for Standard SQL, or MySQL with ONLY_FULL_GROUP_BY (default since 5.7.5).
         * ANY_VALUE() is available from MySQL 5.7.5 https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html
@@ -368,7 +400,7 @@ class Database
        }
 
        /**
-        * @brief Replaces the ? placeholders with the parameters in the $args array
+        * Replaces the ? placeholders with the parameters in the $args array
         *
         * @param string $sql  SQL query
         * @param array  $args The parameters that are to replace the ? placeholders
@@ -395,7 +427,8 @@ class Database
        }
 
        /**
-        * @brief Executes a prepared statement that returns data
+        * Executes a prepared statement that returns data
+        *
         * @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
         *
         * Please only use it with complicated queries.
@@ -458,6 +491,10 @@ class Database
                // We are having an own error logging in the function "e"
                $called_from_e = ($called_from['function'] == 'e');
 
+               if (!isset($this->connection)) {
+                       throw new InternalServerErrorException('The Connection is empty, although connected is set true.');
+               }
+
                switch ($this->driver) {
                        case 'pdo':
                                // If there are no arguments we use "query"
@@ -473,6 +510,7 @@ class Database
                                        break;
                                }
 
+                               /** @var $stmt mysqli_stmt|PDOStatement */
                                if (!$stmt = $this->connection->prepare($sql)) {
                                        $errorInfo     = $this->connection->errorInfo();
                                        $this->error   = $errorInfo[2];
@@ -630,7 +668,7 @@ class Database
        }
 
        /**
-        * @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
+        * Executes a prepared statement like UPDATE or INSERT that doesn't return data
         *
         * Please use DBA::delete, DBA::insert, DBA::update, ... instead
         *
@@ -696,10 +734,10 @@ class Database
        }
 
        /**
-        * @brief Check if data exists
+        * Check if data exists
         *
-        * @param string $table     Table name
-        * @param array  $condition array of fields for condition
+        * @param string|array $table     Table name or array [schema => table]
+        * @param array        $condition array of fields for condition
         *
         * @return boolean Are there rows for that condition?
         * @throws \Exception
@@ -740,7 +778,7 @@ class Database
         *
         * Please use DBA::selectFirst or DBA::exists whenever this is possible.
         *
-        * @brief Fetches the first row
+        * Fetches the first row
         *
         * @param string $sql SQL statement
         *
@@ -765,7 +803,7 @@ class Database
        }
 
        /**
-        * @brief Returns the number of affected rows of the last statement
+        * Returns the number of affected rows of the last statement
         *
         * @return int Number of rows
         */
@@ -775,7 +813,7 @@ class Database
        }
 
        /**
-        * @brief Returns the number of columns of a statement
+        * Returns the number of columns of a statement
         *
         * @param object Statement object
         *
@@ -796,7 +834,7 @@ class Database
        }
 
        /**
-        * @brief Returns the number of rows of a statement
+        * Returns the number of rows of a statement
         *
         * @param PDOStatement|mysqli_result|mysqli_stmt Statement object
         *
@@ -817,7 +855,7 @@ class Database
        }
 
        /**
-        * @brief Fetch a single row
+        * Fetch a single row
         *
         * @param mixed $stmt statement object
         *
@@ -877,51 +915,34 @@ class Database
        }
 
        /**
-        * @brief Insert a row into a table
-        *
-        * @param string/array $table Table name
-        *
-        * @return string formatted and sanitzed table name
-        * @throws \Exception
-        */
-       public function formatTableName($table)
-       {
-               if (is_string($table)) {
-                       return "`" . $this->sanitizeIdentifier($table) . "`";
-               }
-
-               if (!is_array($table)) {
-                       return '';
-               }
-
-               $scheme = key($table);
-
-               return "`" . $this->sanitizeIdentifier($scheme) . "`.`" . $this->sanitizeIdentifier($table[$scheme]) . "`";
-       }
-
-       /**
-        * @brief Insert a row into a table
+        * Insert a row into a table
         *
-        * @param string $table               Table name
-        * @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 bool         $on_duplicate_update Do an update on a duplicate entry
         *
         * @return boolean was the insert successful?
         * @throws \Exception
         */
        public function insert($table, $param, $on_duplicate_update = false)
        {
-
                if (empty($table) || empty($param)) {
                        $this->logger->info('Table and fields have to be set');
                        return false;
                }
 
-               $sql = "INSERT INTO " . $this->formatTableName($table) . " (`" . implode("`, `", array_keys($param)) . "`) VALUES (" .
-                      substr(str_repeat("?, ", count($param)), 0, -2) . ")";
+               $table_string = DBA::buildTableString($table);
+
+               $fields_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], array_keys($param)));
+
+               $values_string = substr(str_repeat("?, ", count($param)), 0, -2);
+
+               $sql = "INSERT INTO " . $table_string . " (" . $fields_string . ") VALUES (" . $values_string . ")";
 
                if ($on_duplicate_update) {
-                       $sql .= " ON DUPLICATE KEY UPDATE `" . implode("` = ?, `", array_keys($param)) . "` = ?";
+                       $fields_string = implode(' = ?, ', array_map([DBA::class, 'quoteIdentifier'], array_keys($param)));
+
+                       $sql .= " ON DUPLICATE KEY UPDATE " . $fields_string . " = ?";
 
                        $values = array_values($param);
                        $param  = array_merge_recursive($values, $values);
@@ -931,7 +952,7 @@ class Database
        }
 
        /**
-        * @brief Fetch the id of the last insert command
+        * Fetch the id of the last insert command
         *
         * @return integer Last inserted id
         */
@@ -949,11 +970,11 @@ class Database
        }
 
        /**
-        * @brief Locks a table for exclusive write access
+        * Locks a table for exclusive write access
         *
         * This function can be extended in the future to accept a table array as well.
         *
-        * @param string $table Table name
+        * @param string|array $table Table name or array [schema => table]
         *
         * @return boolean was the lock successful?
         * @throws \Exception
@@ -968,7 +989,7 @@ class Database
                        $this->connection->autocommit(false);
                }
 
-               $success = $this->e("LOCK TABLES " . $this->formatTableName($table) . " WRITE");
+               $success = $this->e("LOCK TABLES " . DBA::buildTableString($table) . " WRITE");
 
                if ($this->driver == 'pdo') {
                        $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
@@ -987,7 +1008,7 @@ class Database
        }
 
        /**
-        * @brief Unlocks all locked tables
+        * Unlocks all locked tables
         *
         * @return boolean was the unlock successful?
         * @throws \Exception
@@ -1015,7 +1036,7 @@ class Database
        }
 
        /**
-        * @brief Starts a transaction
+        * Starts a transaction
         *
         * @return boolean Was the command executed successfully?
         */
@@ -1043,7 +1064,7 @@ class Database
                return true;
        }
 
-       private function performCommit()
+       protected function performCommit()
        {
                switch ($this->driver) {
                        case 'pdo':
@@ -1061,7 +1082,7 @@ class Database
        }
 
        /**
-        * @brief Does a commit
+        * Does a commit
         *
         * @return boolean Was the command executed successfully?
         */
@@ -1075,7 +1096,7 @@ class Database
        }
 
        /**
-        * @brief Does a rollback
+        * Does a rollback
         *
         * @return boolean Was the command executed successfully?
         */
@@ -1101,7 +1122,7 @@ class Database
        }
 
        /**
-        * @brief Build the array with the table relations
+        * Build the array with the table relations
         *
         * The array is build from the database definitions in DBStructure.php
         *
@@ -1123,7 +1144,9 @@ class Database
        }
 
        /**
-        * @brief Delete a row from a table
+        * Delete a row from a table
+        *
+        * Note: this methods does NOT accept schema => table arrays because of the complex relation stuff.
         *
         * @param string $table      Table name
         * @param array  $conditions Field condition(s)
@@ -1149,13 +1172,11 @@ class Database
 
                // We quit when this key already exists in the callstack.
                if (isset($callstack[$key])) {
-                       return $commands;
+                       return true;
                }
 
                $callstack[$key] = true;
 
-               $table = $this->sanitizeIdentifier($table);
-
                $commands[$key] = ['table' => $table, 'conditions' => $conditions];
 
                // Don't use "defaults" here, since it would set "false" to "true"
@@ -1223,7 +1244,7 @@ class Database
                        $condition_string = DBA::buildCondition($conditions);
 
                        if ((count($command['conditions']) > 1) || is_int($first_key)) {
-                               $sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string;
+                               $sql = "DELETE FROM " . DBA::quoteIdentifier($command['table']) . " " . $condition_string;
                                $this->logger->debug($this->replaceParameters($sql, $conditions));
 
                                if (!$this->e($sql, $conditions)) {
@@ -1251,7 +1272,7 @@ class Database
                foreach ($compacted AS $table => $values) {
                        foreach ($values AS $field => $field_value_list) {
                                foreach ($field_value_list AS $field_values) {
-                                       $sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
+                                       $sql = "DELETE FROM " . DBA::quoteIdentifier($table) . " WHERE " . DBA::quoteIdentifier($field) . " IN (" .
                                               substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
 
                                        $this->logger->debug($this->replaceParameters($sql, $field_values));
@@ -1272,7 +1293,7 @@ class Database
        }
 
        /**
-        * @brief Updates rows
+        * Updates rows
         *
         * Updates rows in the database. When $old_fields is set to an array,
         * the system will only do an update if the fields in that array changed.
@@ -1292,7 +1313,7 @@ class Database
         * Only set $old_fields to a boolean value when you are sure that you will update a single row.
         * When you set $old_fields to "true" then $fields must contain all relevant fields!
         *
-        * @param string        $table      Table name
+        * @param string|array  $table      Table name or array [schema => table]
         * @param array         $fields     contains the fields that are updated
         * @param array         $condition  condition array with the key values
         * @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate)
@@ -1302,14 +1323,11 @@ class Database
         */
        public function update($table, $fields, $condition, $old_fields = [])
        {
-
                if (empty($table) || empty($fields) || empty($condition)) {
                        $this->logger->info('Table, fields and condition have to be set');
                        return false;
                }
 
-               $condition_string = DBA::buildCondition($condition);
-
                if (is_bool($old_fields)) {
                        $do_insert = $old_fields;
 
@@ -1324,28 +1342,26 @@ class Database
                        }
                }
 
-               $do_update = (count($old_fields) == 0);
-
                foreach ($old_fields AS $fieldname => $content) {
-                       if (isset($fields[$fieldname])) {
-                               if (($fields[$fieldname] == $content) && !is_null($content)) {
-                                       unset($fields[$fieldname]);
-                               } else {
-                                       $do_update = true;
-                               }
+                       if (isset($fields[$fieldname]) && !is_null($content) && ($fields[$fieldname] == $content)) {
+                               unset($fields[$fieldname]);
                        }
                }
 
-               if (!$do_update || (count($fields) == 0)) {
+               if (count($fields) == 0) {
                        return true;
                }
 
-               $sql = "UPDATE " . $this->formatTableName($table) . " SET `" .
-                      implode("` = ?, `", array_keys($fields)) . "` = ?" . $condition_string;
+               $table_string = DBA::buildTableString($table);
+
+               $condition_string = DBA::buildCondition($condition);
+
+               $sql = "UPDATE " . $table_string . " SET "
+                       . implode(" = ?, ", array_map([DBA::class, 'quoteIdentifier'], array_keys($fields))) . " = ?"
+                       . $condition_string;
 
-               $params1 = array_values($fields);
-               $params2 = array_values($condition);
-               $params  = array_merge_recursive($params1, $params2);
+               // Combines the updated fields parameter values with the condition parameter values
+               $params  = array_merge(array_values($fields), $condition);
 
                return $this->e($sql, $params);
        }
@@ -1353,12 +1369,10 @@ class Database
        /**
         * Retrieve a single record from a table and returns it in an associative array
         *
-        * @brief Retrieve a single record from a table
-        *
-        * @param string $table
-        * @param array  $fields
-        * @param array  $condition
-        * @param array  $params
+        * @param string|array $table
+        * @param array        $fields
+        * @param array        $condition
+        * @param array        $params
         *
         * @return bool|array
         * @throws \Exception
@@ -1379,12 +1393,29 @@ class Database
        }
 
        /**
-        * @brief Select rows from a table
+        * Select rows from a table and fills an array with the data
+        *
+        * @param string|array $table     Table name or array [schema => table]
+        * @param array        $fields    Array of selected fields, empty for all
+        * @param array        $condition Array of fields for condition
+        * @param array        $params    Array of several parameters
+        *
+        * @return array Data array
+        * @throws \Exception
+        * @see   self::select
+        */
+       public function selectToArray($table, array $fields = [], array $condition = [], array $params = [])
+       {
+               return $this->toArray($this->select($table, $fields, $condition, $params));
+       }
+
+       /**
+        * Select rows from a table
         *
-        * @param string $table     Table name
-        * @param array  $fields    Array of selected fields, empty for all
-        * @param array  $condition Array of fields for condition
-        * @param array  $params    Array of several parameters
+        * @param string|array $table     Table name or array [schema => table]
+        * @param array        $fields    Array of selected fields, empty for all
+        * @param array        $condition Array of fields for condition
+        * @param array        $params    Array of several parameters
         *
         * @return boolean|object
         *
@@ -1408,16 +1439,18 @@ class Database
                }
 
                if (count($fields) > 0) {
-                       $select_fields = "`" . implode("`, `", array_values($fields)) . "`";
+                       $select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $fields));
                } else {
-                       $select_fields = "*";
+                       $select_string = '*';
                }
 
+               $table_string = DBA::buildTableString($table);
+
                $condition_string = DBA::buildCondition($condition);
 
                $param_string = DBA::buildParameter($params);
 
-               $sql = "SELECT " . $select_fields . " FROM " . $this->formatTableName($table) . $condition_string . $param_string;
+               $sql = "SELECT " . $select_string . " FROM " . $table_string . $condition_string . $param_string;
 
                $result = $this->p($sql, $condition);
 
@@ -1425,10 +1458,11 @@ class Database
        }
 
        /**
-        * @brief Counts the rows from a table satisfying the provided condition
+        * Counts the rows from a table satisfying the provided condition
         *
-        * @param string $table     Table name
-        * @param array  $condition array of fields for condition
+        * @param string|array $table     Table name or array [schema => table]
+        * @param array        $condition Array of fields for condition
+        * @param array        $params    Array of several parameters
         *
         * @return int
         *
@@ -1442,15 +1476,25 @@ class Database
         * $count = DBA::count($table, $condition);
         * @throws \Exception
         */
-       public function count($table, array $condition = [])
+       public function count($table, array $condition = [], array $params = [])
        {
                if (empty($table)) {
                        return false;
                }
 
+               $table_string = DBA::buildTableString($table);
+
                $condition_string = DBA::buildCondition($condition);
 
-               $sql = "SELECT COUNT(*) AS `count` FROM " . $this->formatTableName($table) . $condition_string;
+               if (empty($params['expression'])) {
+                       $expression = '*';
+               } elseif (!empty($params['distinct'])) {
+                       $expression = "DISTINCT " . DBA::quoteIdentifier($params['expression']);
+               } else {
+                       $expression = DBA::quoteIdentifier($params['expression']);
+               }
+
+               $sql = "SELECT COUNT(" . $expression . ") AS `count` FROM " . $table_string . $condition_string;
 
                $row = $this->fetchFirst($sql, $condition);
 
@@ -1458,7 +1502,7 @@ class Database
        }
 
        /**
-        * @brief Fills an array with data from a query
+        * Fills an array with data from a query
         *
         * @param object $stmt statement object
         * @param bool   $do_close
@@ -1468,21 +1512,23 @@ class Database
        public function toArray($stmt, $do_close = true)
        {
                if (is_bool($stmt)) {
-                       return $stmt;
+                       return [];
                }
 
                $data = [];
                while ($row = $this->fetch($stmt)) {
                        $data[] = $row;
                }
+
                if ($do_close) {
                        $this->close($stmt);
                }
+
                return $data;
        }
 
        /**
-        * @brief Returns the error number of the last query
+        * Returns the error number of the last query
         *
         * @return string Error number (0 if no error)
         */
@@ -1492,7 +1538,7 @@ class Database
        }
 
        /**
-        * @brief Returns the error message of the last query
+        * Returns the error message of the last query
         *
         * @return string Error message ('' if no error)
         */
@@ -1502,7 +1548,7 @@ class Database
        }
 
        /**
-        * @brief Closes the current statement
+        * Closes the current statement
         *
         * @param object $stmt statement object
         *
@@ -1543,7 +1589,7 @@ class Database
        }
 
        /**
-        * @brief Return a list of database processes
+        * Return a list of database processes
         *
         * @return array
         *      'list' => List of processes, separated in their different states
@@ -1599,7 +1645,7 @@ class Database
        }
 
        /**
-        * @brief Callback function for "esc_array"
+        * Callback function for "esc_array"
         *
         * @param mixed   $value         Array value
         * @param string  $key           Array key
@@ -1628,7 +1674,7 @@ class Database
        }
 
        /**
-        * @brief Escapes a whole array
+        * Escapes a whole array
         *
         * @param mixed   $arr           Array with values to be escaped
         * @param boolean $add_quotation add quotation marks for string values