summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavey Shafik <me@daveyshafik.com>2016-01-28 16:14:56 +0100
committerDavey Shafik <me@daveyshafik.com>2016-02-02 12:50:51 -0500
commite2f4aeb61cae100653b61c10a1424771eb6ff25c (patch)
tree7af810a0babe1d6420c42551bd7044427235616f /lib
parent3d5a14dbea4538a87ddbcfc19c3ac1dc00c475e1 (diff)
downloadphp7-mysql-shim-e2f4aeb61cae100653b61c10a1424771eb6ff25c.zip
php7-mysql-shim-e2f4aeb61cae100653b61c10a1424771eb6ff25c.tar.gz
php7-mysql-shim-e2f4aeb61cae100653b61c10a1424771eb6ff25c.tar.bz2
Fix return values for `mysql_fetch_*` functions
The methods `mysql_fetch_* and `mysqli_fetch_*` have different return values, if there is no [more] results to fetch. Therefore the **null** return value of `mysqli` needs to be matched to the **false** return value of `mysql`. Thanks to @muhammedalialat
Diffstat (limited to 'lib')
-rw-r--r--lib/mysql.php13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/mysql.php b/lib/mysql.php
index 91d8a29..03bd7e3 100644
--- a/lib/mysql.php
+++ b/lib/mysql.php
@@ -284,7 +284,7 @@ namespace {
return false;
// @codeCoverageIgnoreEnd
}
- return mysqli_fetch_row($result);
+ return mysqli_fetch_row($result) ?: false;
}
function mysql_fetch_array($result)
@@ -294,7 +294,7 @@ namespace {
return false;
// @codeCoverageIgnoreEnd
}
- return mysqli_fetch_array($result);
+ return mysqli_fetch_array($result) ?: false;
}
function mysql_fetch_assoc($result) /* : array|null */
@@ -304,7 +304,8 @@ namespace {
return false;
// @codeCoverageIgnoreEnd
}
- return mysqli_fetch_assoc($result);
+
+ return mysqli_fetch_assoc($result) ?: false;
}
function mysql_fetch_object($result, $class = null, array $params = []) /* : object|null */
@@ -321,11 +322,7 @@ namespace {
$object = mysqli_fetch_object($result, $class, $params);
}
- if($object == null) {
- return false;
- }
-
- return $object;
+ return $object ?: false;
}
function mysql_data_seek($result, $offset)