Am 24.03.2005 um 12:32 schrieb Jared Williams:


$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



i really think that is wrong:

(a) NULL is a valid value for a string.
(b)  bindParam should not change the type of a passed in php-variable.

my patch actually only "solves" (a) -- we should also fix (b). to do this we need to:
- leave the php-var (zval) untouched in bindParam (except for bumping the refcount)
- when we "need" the string value (during execute) we need to seperate and convert so that the original zval keeps its type.



re, thies

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to