preventing crash if there's no error to display.

This commit is contained in:
2023-08-22 11:51:46 -04:00
parent 3f0d17de31
commit dee615e7f0

View File

@@ -3,7 +3,7 @@
/**
* @desc A simple and convenient php sqlsrv class
* @author Originaly made by Yaseng WwW.Yaseng.Me, now maintained and update by Sebastien Plante
* @version v1.4
* @version v1.5
* @link https://gitea.urbanghetto.net/nka/php_sqlsrv_class
*/
@@ -22,7 +22,7 @@ class sqlsrv
$this->conn = @sqlsrv_connect($server, array('UID' => $user, 'PWD' => $pass, 'Database' => $dbname, 'LoginTimeout' => 10));
if ($this->conn === false) {
$this->error_log[] = sqlsrv_errors();
throw new Exception($this->error_log[0][0]["message"]);
throw new Exception(($this->error_log[0][0]["message"] ?? ''));
}
}
@@ -33,7 +33,7 @@ class sqlsrv
$this->sql_log[] = $sql;
if ($stmt === false) {
$this->error_log[] = sqlsrv_errors();
throw new Exception($this->error_log[0][0]["message"]);
throw new Exception(($this->error_log[0][0]["message"] ?? ''));
} else {
$this->query_id = $stmt;
$this->num_rows = $this->affectedRows();
@@ -67,7 +67,7 @@ class sqlsrv
$stmt = sqlsrv_query($this->conn, $sql, $params);
if ($stmt === false) {
throw new Exception($this->error_log[0][0]["message"]);
throw new Exception(($this->error_log[0][0]["message"] ?? ''));
} else {
$data = array();
while ($row = @sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
@@ -84,7 +84,7 @@ class sqlsrv
$stmt = sqlsrv_query($this->conn, $sql, $params);
if ($stmt === false) {
throw new Exception($this->error_log[0][0]["message"]);
throw new Exception(($this->error_log[0][0]["message"] ?? ''));
} else {
return sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
}