note 111266 added to mysqli.prepare
| From: | at runspired | Date: | Thu, 31 Jan 2013 16:42:43 +0000 |
| Subject: | note 111266 added to mysqli.prepare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193468@lists.php.net to get a copy of this message | ||
I don't think this is a bug, just an unexpected behavior. While building an API I discovered
that passing INT 0 instead of STRING '0' into a prepared statement caused my script to run
out of memory and produce a 500error on the webpage.
A simplified example of this issue is below: ($_DB is a global reference to a mysqli connection)
<?php
function getItem( $ID ) {
$_STATEMENT = $_DB->prepare("SELECT item_user, item_name, item_description FROM item
WHERE item_id = ?;");
$_STATEMENT->bind_param( 'i' , $ID );
$_STATEMENT->execute();
$_STATEMENT->store_result();
$_STATEMENT->bind_result( $user , $name , $description);
$result = $_STATEMENT->fetch();
$_STATEMENT->free_result();
$_STATEMENT->close();
return $result;
}
getItem(0); //fails!
getItem('0'); //works!
?>
The best I can guess is that an INT 0 gets translated as BOOLEAN , and if this is indeed the case it
should be documented above, but all efforts to get error information (via the php script) have
failed.
----
Server IP: 69.147.83.199
Probable Submitter: 98.206.167.137
----
Manual Page -- http://php.net/manual/en/mysqli.prepare.php
Edit -- https://master.php.net/note/edit/111266
Del: integrated -- https://master.php.net/note/delete/111266/integrated
Del: useless -- https://master.php.net/note/delete/111266/useless
Del: bad code -- https://master.php.net/note/delete/111266/bad+code
Del: spam -- https://master.php.net/note/delete/111266/spam
Del: non-english -- https://master.php.net/note/delete/111266/non-english
Del: in docs -- https://master.php.net/note/delete/111266/in+docs
Del: other reasons-- https://master.php.net/note/delete/111266
Reject -- https://master.php.net/note/reject/111266
Search -- https://master.php.net/manage/user-notes.php