Skip to content

Commit

Permalink
Update php7-compat.php
Browse files Browse the repository at this point in the history
proposed change for mysql_connect with new link
  • Loading branch information
dafuki committed Jan 20, 2021
1 parent a0c8b2e commit a5d94fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions php7-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ function mysql_close($link = null)
{
function mysql_connect($server = '', $user = '', $password = '', $new_link = false, $client_flags = 0)
{
global $_php7_compat_global_db_link;
if (!$new_link)
{
global $_php7_compat_global_db_link;
$link = $_php7_compat_global_db_link;
}

if (!$server) $server = ini_get('mysqli.default_host');
if (!$user) $user = ini_get('mysqli.default_user');
if (!$password) $password = ini_get('mysqli.default_pw');

$link = mysqli_connect($server, $user, $password);
if (!$_php7_compat_global_db_link) $_php7_compat_global_db_link = $link;
if (!$_php7_compat_global_db_link && !$new_link) $_php7_compat_global_db_link = $link;
return $link;
}
}
Expand Down

0 comments on commit a5d94fa

Please sign in to comment.