[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-bugs
Subject: [DOC-BUGS] Doc #75448 [Opn]: In case of failure, mysqli::prepare() returns NULL instead of FALSE
From: "morozov at tut dot by" <php-bugs () lists ! php ! net>
Date: 2017-10-29 19:25:33
Message-ID: 201710291925.v9TJPXhh013964 () srgv2 ! php ! net
[Download RAW message or body]
Edit report at https://bugs.php.net/bug.php?id=75448&edit=1
ID: 75448
User updated by: morozov at tut dot by
Reported by: morozov at tut dot by
Summary: In case of failure, mysqli::prepare() returns NULL
instead of FALSE
Status: Open
Type: Documentation Problem
Package: MySQLi related
Operating System: Linux
PHP Version: 7.1.11
Block user comment: N
Private report: N
New Comment:
It may be a common thing but it's still a bug. As far as I understand the design, all \
`mysqli_*` functions should return FALSE on failure, and a user can call \
`mysqli_error()` and friends to get the error details. What's the point of returning \
FALSE in some cases but NULL in others?
Previous Comments:
------------------------------------------------------------------------
[2017-10-29 08:29:17] kalle@php.net
I think this is a common thing in the mysqli extension to simply return null if the \
"active connection" check fails, so instead the docs should be updated to reflect thi
------------------------------------------------------------------------
[2017-10-28 03:05:15] morozov at tut dot by
Description:
------------
According to http://php.net/mysqli_prepare, mysqli_prepare() returns a statement \
object or FALSE if an error occurred. Under certain circumstances, it also returns \
NULL which makes error handling harder.
Test script:
---------------
<?php
$conn = mysqli_connect('localhost', 'root', '');
$conn->close();
$stmt = $conn->prepare('SELECT * FROM users');
var_dump($stmt);
Expected result:
----------------
The value of $stmt is FALSE.
Actual result:
--------------
The value of $stmt is NULL.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75448&edit=1
--
PHP Documentation Bugs Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic