summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavey Shafik <me@daveyshafik.com>2020-08-11 19:00:41 +0000
committerDavey Shafik <me@daveyshafik.com>2020-08-11 19:00:41 +0000
commit7a44f0d9b88455aeea81503a77b19c6bfd4aa61b (patch)
treed5a812d09816f162866f2a67259e739ea812b4f2 /lib
parentca00c4ff31e631032388adb15322adcdee4e13dd (diff)
downloadphp7-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')
-rw-r--r--lib/mysql.php18
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;
}