mysql_ vs mysqli_ return values
theriftlab opened this issue · 3 comments
theriftlab commented
Apologies as I'm unfamiliar with GitHub, but the 4 fetch functions: mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_row()
and mysql_fetch_object()
all natively returned FALSE on failure, whereas the mysqli_XXX()
fetch functions return NULL.
In the case of a conditional such as this:
while (($row = mysql_fetch(assoc($query) !== FALSE)
your drop-in functions will cause this to loop indefinitely and time out. Personally I've used the following template for all 4 functions, which seems to work with old code that contains the above conditionals:
function mysql_fetch_assoc($result) {
$row = mysqli_fetch_assoc($result);
return is_null($row) ? false : $row;
}
rubo77 commented
Great, can you create a pull request please?
theriftlab commented
Hopefully I've done that correctly (I never use GitHub).
rubo77 commented
Thanks