Hello Matteo,

-----Original Message-----
From: Matteo Beccati [mailto:p...@beccati.com] 
Sent: Thursday, May 18, 2017 8:13 AM

>> But when implementing FB Boolean data type parameters and doing 
>> ->bindValue ('bool_param', false) I get an empty string internally.
>> 
>> Yes, true ZVAL is converted as string as '1', but false as an empty 
>> string, not so consistent here ;)

>That's not true.

>$p = new PDO("pgsql:dbname=postgres");
>$p->prepare("SELECT ?::bool");
>$s->bindValue(1, false);
>$s->execute();
>var_dump($s->fetchColumn());'

>outputs:
>bool(false)

>What are you referring to?

I wrote "internally", meaning in C driver code, not in PHP.
When a bool ZVAL variable is converted to a string ZVAL.
Your example is irrelevant.


>> That's why I think, it will be great to have a special type like 
>> PDO::PARAM_AUTO and a config flag to set it as default instead of PARAM_STR.

>Config flags are evil as it's one more thing you'd need to be aware of and 
>could change depending on the environment you run your script or library on.

Maybe I was not so explicit, I meant an option flag in PDO constructor in order 
to not break existing code, not a hardcoded global config in php.ini
Here: public PDO::__construct ( string $dsn [, string $username [, string 
$password [, array $options ]]] )
something like PDO::PARAM_AUTO => true or "server param data types", we should 
think for a good name.

But I'm with all hands up for making PDO::PARAM_AUTO default in bindValue, just 
it may require some small adjustments in all PDO drivers.
If server type params are not supported, treat them as strings. So it should 
work.


-
  D.


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

Reply via email to