diff options
author | Davey Shafik <me@daveyshafik.com> | 2016-10-03 10:28:52 -0700 |
---|---|---|
committer | Davey Shafik <me@daveyshafik.com> | 2016-10-03 10:28:52 -0700 |
commit | 5a38260835db8b75185aeb6e41b9bd688fcd8a91 (patch) | |
tree | bdb90fdbcfe16433d7f999439b9452be94cdfd89 /lib/mysql.php | |
parent | cfbbe478a65a8ca8ea4ef0df2671fc1bfcfa81b8 (diff) | |
download | php7-mysql-shim-5a38260835db8b75185aeb6e41b9bd688fcd8a91.zip php7-mysql-shim-5a38260835db8b75185aeb6e41b9bd688fcd8a91.tar.gz php7-mysql-shim-5a38260835db8b75185aeb6e41b9bd688fcd8a91.tar.bz2 |
Add comments
Diffstat (limited to 'lib/mysql.php')
-rw-r--r-- | lib/mysql.php | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/mysql.php b/lib/mysql.php index a777925..21d625b 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -31,12 +31,14 @@ namespace { } $hash = sha1($hostname . $username . $flags); + /* persistent connections start with p: */ if ($hostname{1} != ':' && isset(\Dshafik\MySQL::$connections[$hash])) { \Dshafik\MySQL::$last_connection = \Dshafik\MySQL::$connections[$hash]['conn']; \Dshafik\MySQL::$connections[$hash]['refcount'] += 1; return \Dshafik\MySQL::$connections[$hash]['conn']; } + /* No flags, means we can use mysqli_connect() */ if ($flags === 0) { $conn = mysqli_connect($hostname, $username, $password); if (!$conn instanceof mysqli) { @@ -49,6 +51,7 @@ namespace { return $conn; } + /* Flags means we need to use mysqli_real_connect() instead, and handle exceptions */ try { \Dshafik\MySQL::$last_connection = $conn = mysqli_init(); |