Merge pull request #5271 from miqrogroove/patch-1

Correct dba::close() To Match dba::p()
This commit is contained in:
Hypolite Petovan 2018-06-21 22:11:13 -04:00 committed by GitHub
commit 438dea8cc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -349,7 +349,7 @@ class dba {
* For all regular queries please use dba::select or dba::exists
*
* @param string $sql SQL statement
* @return bool|object statement object
* @return bool|object statement object or result object
*/
public static function p($sql) {
$a = get_app();
@ -1404,8 +1404,18 @@ class dba {
$ret = $stmt->closeCursor();
break;
case 'mysqli':
// MySQLi offers both a mysqli_stmt and a mysqli_result class.
// We should be careful not to assume the object type of $stmt
// because dba::p() has been able to return both types.
if ($stmt instanceof mysqli_stmt) {
$stmt->free_result();
$ret = $stmt->close();
} elseif ($stmt instanceof mysqli_result) {
$stmt->free();
$ret = true;
} else {
$ret = false;
}
break;
}