]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/Database.php
Merge pull request #9806 from Extarys/actionfade
[friendica.git] / src / Database / Database.php
index 641ebd3894dc1fa4f68a3d9996b38918696079be..ae06f00e26cd5562e425008b773a833eb777855e 100644 (file)
@@ -64,7 +64,6 @@ class Database
        /** @var PDO|mysqli */
        protected $connection;
        protected $driver;
-       protected $emulate_prepares = false;
        protected $pdo_emulate_prepares = false;
        private $error          = false;
        private $errorno        = 0;
@@ -122,7 +121,6 @@ class Database
 
                $persistent = (bool)$this->configCache->get('database', 'persistent');
 
-               $this->emulate_prepares = (bool)$this->configCache->get('database', 'emulate_prepares');
                $this->pdo_emulate_prepares = (bool)$this->configCache->get('database', 'pdo_emulate_prepares');
 
                if (!$this->configCache->get('database', 'disable_pdo') && class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
@@ -457,7 +455,7 @@ class Database
        /**
         * Executes a prepared statement that returns data
         *
-        * @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
+        * @usage 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
@@ -527,7 +525,7 @@ class Database
                switch ($this->driver) {
                        case self::PDO:
                                // If there are no arguments we use "query"
-                               if ($this->emulate_prepares || count($args) == 0) {
+                               if (count($args) == 0) {
                                        if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
                                                $errorInfo     = $this->connection->errorInfo();
                                                $this->error   = $errorInfo[2];
@@ -577,7 +575,7 @@ class Database
                                $can_be_prepared = in_array($command, ['select', 'update', 'insert', 'delete']);
 
                                // The fallback routine is called as well when there are no arguments
-                               if ($this->emulate_prepares || !$can_be_prepared || (count($args) == 0)) {
+                               if (!$can_be_prepared || (count($args) == 0)) {
                                        $retval = $this->connection->query($this->replaceParameters($sql, $args));
                                        if ($this->connection->errno) {
                                                $this->error   = $this->connection->error;
@@ -910,13 +908,12 @@ class Database
        /**
         * Fetch a single row
         *
-        * @param mixed $stmt statement object
+        * @param PDOStatement|mysqli_stmt $stmt statement object
         *
-        * @return array current row
+        * @return array|false current row
         */
        public function fetch($stmt)
        {
-
                $stamp1 = microtime(true);
 
                $columns = [];
@@ -934,7 +931,7 @@ class Database
                                break;
                        case self::MYSQLI:
                                if (get_class($stmt) == 'mysqli_result') {
-                                       $columns = $stmt->fetch_assoc();
+                                       $columns = $stmt->fetch_assoc() ?? false;
                                        break;
                                }