Quickfix for SQL commands that should return "true" instead of an empty array

This commit is contained in:
Michael 2017-03-06 10:10:22 +00:00
parent 2ea50d9c47
commit d686bdcf09

View file

@ -63,18 +63,21 @@ class dba {
$this->db = @new mysqli($server,$user,$pass,$db); $this->db = @new mysqli($server,$user,$pass,$db);
if (!mysqli_connect_errno()) { if (!mysqli_connect_errno()) {
$this->connected = true; $this->connected = true;
}
if (isset($a->config["system"]["db_charset"])) { if (isset($a->config["system"]["db_charset"])) {
$this->db->set_charset($a->config["system"]["db_charset"]); $this->db->set_charset($a->config["system"]["db_charset"]);
}
} }
} elseif (function_exists('mysql_connect')) { } elseif (function_exists('mysql_connect')) {
$this->driver = 'mysql'; $this->driver = 'mysql';
$this->db = mysql_connect($server,$user,$pass); $this->db = mysql_connect($server,$user,$pass);
if ($this->db && mysql_select_db($db,$this->db)) { if ($this->db && mysql_select_db($db,$this->db)) {
$this->connected = true; $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 { } else {
// No suitable SQL driver was found. // No suitable SQL driver was found.
if (!$install) { if (!$install) {
@ -334,9 +337,6 @@ class dba {
if (file_exists('dbfail.out')) { if (file_exists('dbfail.out')) {
file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND); 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)) { if (($result === true) || ($result === false)) {
@ -372,6 +372,11 @@ class dba {
break; 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"); //$a->save_timestamp($stamp1, "database");
if ($this->debug) { if ($this->debug) {