note 103144 added to mysqli-stmt.bind-param
| From: | Anonymous at osu1 dot php dot net | Date: | Mon, 28 Mar 2011 21:49:51 +0000 |
| Subject: | note 103144 added to mysqli-stmt.bind-param | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178283@lists.php.net to get a copy of this message | ||
You can bind to variables with NULL values, and on update and insert queries, the corresponding
field will be updated to NULL no matter what bind string type you associated it with. But, for
parameters meant for the WHERE clause (ie where field = ?), the query will have no effect and
produce no results.
When comparing a value against NULL, the MYSQL syntax is either "value IS NULL" or
"value IS NOT NULL". So, you can't pass in something like "WHERE (value =
?)" and expect this to work using a null value parameter.
Instead, you can do something like this in your WHERE clause:
"WHERE (IF(ISNULL(?), field1 is null, field1 = ?))"
Then, pass in the value you want to test twice:
bind_param('ss', $value1, $value1);
----
Server IP: 208.69.120.55
Probable Submitter: 65.36.73.107
----
Manual Page -- http://www.php.net/manual/en/mysqli-stmt.bind-param.php
Edit -- https://master.php.net/note/edit/103144
Del: integrated -- https://master.php.net/note/delete/103144/integrated
Del: useless -- https://master.php.net/note/delete/103144/useless
Del: bad code -- https://master.php.net/note/delete/103144/bad+code
Del: spam -- https://master.php.net/note/delete/103144/spam
Del: non-english -- https://master.php.net/note/delete/103144/non-english
Del: in docs -- https://master.php.net/note/delete/103144/in+docs
Del: other reasons-- https://master.php.net/note/delete/103144
Reject -- https://master.php.net/note/reject/103144
Search -- https://master.php.net/manage/user-notes.php