diff options
Diffstat (limited to 'lib/mysql.php')
-rw-r--r-- | lib/mysql.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/mysql.php b/lib/mysql.php index f93c9cd..215e045 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -40,6 +40,10 @@ namespace { $new = false, $flags = 0 ) { + if ($new !== false) { + trigger_error('Argument $new is no longer supported in PHP > 7', E_USER_WARNING); + } + if (null === $hostname) { $hostname = ini_get('mysqli.default_host') ?: null; } @@ -53,7 +57,7 @@ namespace { $hash = sha1($hostname . $username . $flags); /* persistent connections start with p: */ /* don't use a cached link for those */ - if (!$new && $hostname[1] !== ':' && isset(\Dshafik\MySQL::$connections[$hash])) { + 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']; @@ -408,14 +412,16 @@ namespace { // @codeCoverageIgnoreEnd } $res = mysqli_fetch_field($result); - $res->not_null = ($res->flags & MYSQLI_NOT_NULL_FLAG) ? 1 : 0; - $res->primary_key = ($res->flags & MYSQLI_PRI_KEY_FLAG ) ? 1 : 0; - $res->unique_key = ($res->flags & MYSQLI_UNIQUE_KEY_FLAG ) ? 1 : 0; - $res->multiple_key = ($res->flags & MYSQLI_MULTIPLE_KEY_FLAG ) ? 1 : 0; - $res->numeric = ($res->flags & MYSQLI_NUM_FLAG ) ? 1 : 0; - $res->blob = ($res->flags & MYSQLI_BLOB_FLAG ) ? 1 : 0; - $res->unsigned = ($res->flags & MYSQLI_UNSIGNED_FLAG ) ? 1 : 0; - $res->zerofill = ($res->flags & MYSQLI_ZEROFILL_FLAG ) ? 1 : 0; + if ($res instanceof \stdClass) { + $res->not_null = ($res->flags & MYSQLI_NOT_NULL_FLAG) ? 1 : 0; + $res->primary_key = ($res->flags & MYSQLI_PRI_KEY_FLAG ) ? 1 : 0; + $res->unique_key = ($res->flags & MYSQLI_UNIQUE_KEY_FLAG ) ? 1 : 0; + $res->multiple_key = ($res->flags & MYSQLI_MULTIPLE_KEY_FLAG ) ? 1 : 0; + $res->numeric = ($res->flags & MYSQLI_NUM_FLAG ) ? 1 : 0; + $res->blob = ($res->flags & MYSQLI_BLOB_FLAG ) ? 1 : 0; + $res->unsigned = ($res->flags & MYSQLI_UNSIGNED_FLAG ) ? 1 : 0; + $res->zerofill = ($res->flags & MYSQLI_ZEROFILL_FLAG ) ? 1 : 0; + } return $res; } |