1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 02:39:46 +02:00
This commit is contained in:
Daniel Neto 2025-04-13 17:02:44 -03:00
parent 2aedcec608
commit 2eee104d9b

View file

@ -247,26 +247,35 @@ function _mysql_close()
} }
} }
/**
* Check if the MySQL connection is open and valid.
*
* @return bool True if the connection is open, false otherwise.
*/
function _mysql_is_open() function _mysql_is_open()
{ {
global $global, $mysql_connect_was_closed; global $global, $mysql_connect_was_closed;
try { try {
/** if (!empty($global['mysqli']) && ($global['mysqli'] instanceof mysqli) && empty($mysql_connect_was_closed)) {
* if ($global['mysqli']->ping()) {
* @var array $global return true;
* @var object $global['mysqli'] } else {
*/ error_log("MySQL connection ping failed: " . $global['mysqli']->error);
//if (is_object($global['mysqli']) && (empty($mysql_connect_was_closed) || !empty(@$global['mysqli']->ping()))) { }
if (!empty($global['mysqli']) && is_object($global['mysqli']) && empty($mysql_connect_was_closed) && isset($global['mysqli']->server_info) && is_resource($global['mysqli']) && get_resource_type($global['mysqli']) === 'mysql link') { } else {
return true; error_log("MySQL connection object is either empty, not an instance of mysqli, or has been marked as closed.");
} }
} catch (Exception $exc) { } catch (Exception $exc) {
error_log("Exception in _mysql_is_open: " . $exc->getMessage());
return false; return false;
} }
return false; return false;
} }
function lockForUpdate($tableName, $condition) function lockForUpdate($tableName, $condition)
{ {
global $global; global $global;