From: Michael Date: Mon, 6 Mar 2017 10:10:22 +0000 (+0000) Subject: Quickfix for SQL commands that should return "true" instead of an empty array X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d686bdcf0905c82780e0c4edd79638dcef67825c;p=friendica.git Quickfix for SQL commands that should return "true" instead of an empty array --- diff --git a/include/dba.php b/include/dba.php index 000b5b49ec..3742ba7018 100644 --- a/include/dba.php +++ b/include/dba.php @@ -63,18 +63,21 @@ class dba { $this->db = @new mysqli($server,$user,$pass,$db); if (!mysqli_connect_errno()) { $this->connected = true; - } - if (isset($a->config["system"]["db_charset"])) { - $this->db->set_charset($a->config["system"]["db_charset"]); + + if (isset($a->config["system"]["db_charset"])) { + $this->db->set_charset($a->config["system"]["db_charset"]); + } } } elseif (function_exists('mysql_connect')) { $this->driver = 'mysql'; $this->db = mysql_connect($server,$user,$pass); if ($this->db && mysql_select_db($db,$this->db)) { $this->connected = true; + + if (isset($a->config["system"]["db_charset"])) { + mysql_set_charset($a->config["system"]["db_charset"], $this->db); + } } - if (isset($a->config["system"]["db_charset"])) - mysql_set_charset($a->config["system"]["db_charset"], $this->db); } else { // No suitable SQL driver was found. if (!$install) { @@ -334,9 +337,6 @@ class dba { if (file_exists('dbfail.out')) { file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND); } - } elseif (($this->driver == 'pdo') AND (strtolower(substr($orig_sql, 0, 6)) != "select")) { - // mysqli separates the return value between "select" and "update" - pdo doesn't - $result = true; } if (($result === true) || ($result === false)) { @@ -372,6 +372,11 @@ class dba { break; } + if (($this->driver == 'pdo') AND (strtolower(substr($orig_sql, 0, 6)) != "select") AND (count($r) == 0)) { + // mysqli separates the return value between "select" and "update" - pdo doesn't + $r = true; + } + //$a->save_timestamp($stamp1, "database"); if ($this->debug) {