RE: [PHP-DEV] pdo: cannot send NULL values thru bound parameters.
| From: | Jared Williams | Date: | Thu, 24 Mar 2005 11:32:40 +0000 |
| Subject: | RE: [PHP-DEV] pdo: cannot send NULL values thru bound parameters. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-15573@lists.php.net to get a copy of this message | ||
> $stmt = $this->prepareStatement('insert into bla (name)
> values (:name)'); $name = NULL; var_dump($name); // $name is
> NULL $stmt->bindParam(':name', $name); var_dump($name); //
> $name is an empty string
>
> am i overlooking something obvious?
$stmt->bindParam(':name', $name, PDO_PARAM_NULL);
Or
$stmt->bindParam(':name', $name, is_null($name) ? PDO_PARAM_NULL : PDO_PARAM_STR);
Is what I've been using, and works. http://pecl.php.net/bugs/bug.php?id=3391 was the
original bug report I opened, that's since been
fixed.
Jared