diff options
author | Davey Shafik <me@daveyshafik.com> | 2020-08-11 19:00:41 +0000 |
---|---|---|
committer | Davey Shafik <me@daveyshafik.com> | 2020-08-11 19:00:41 +0000 |
commit | 7a44f0d9b88455aeea81503a77b19c6bfd4aa61b (patch) | |
tree | d5a812d09816f162866f2a67259e739ea812b4f2 /lib/mysql.php | |
parent | ca00c4ff31e631032388adb15322adcdee4e13dd (diff) | |
download | php7-mysql-shim-7a44f0d9b88455aeea81503a77b19c6bfd4aa61b.zip php7-mysql-shim-7a44f0d9b88455aeea81503a77b19c6bfd4aa61b.tar.gz php7-mysql-shim-7a44f0d9b88455aeea81503a77b19c6bfd4aa61b.tar.bz2 |
Don't try to assign fields if the fetch failed
Diffstat (limited to 'lib/mysql.php')
-rw-r--r-- | lib/mysql.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/mysql.php b/lib/mysql.php index 1ca8434..215e045 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -412,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; } |