Hi Adam,
> From: Adam Baratz [mailto:adambaratz@php.net]
> Sent: Thursday, May 18, 2017 3:23 PM
>> 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.
> The risk with this is queries could lose portability between drivers. There are differences in the level of information each one can get from the DB server, and different costs associated with asking.
> I think the right model is to have PDO types map directly to SQL types. That said, the code and documentation don't take a strong stance on how types should work. And there's not a lot of agreement in the community, at least as indicated by discussions on this list.
Yes, agree about portability. But from other side, it will be a great benefit for drivers that supports server side prepares, not just emulation.
Maybe even a better way is just to change default param type from PARAM_STR to PARAM_AUTO in bindValue family routines, without any driver options or configs.
So if drivers supports server prepares with type hinting, OK: treat it better, if not, push it as a string like is now.
Anyway, there is not a documented standard what driver should do when you pass something like bindValue('param', '', PDO::PARAM_BOOL) or bindValue('param', 't', PDO::PARAM_BOOL) or bindValue('param', '0', PDO::PARAM_BOOL)
In case if data type is specified, then force it, as dictate the php code.
What do you think?
> I agree with Matteo that param hooks might provide a better solution to the specific problem you're describing.
I'm using this way, just now. But I don’t like the way that code
->BindValue('bool_param', false);
give me internally in C driver code a string type ZVAL with an empty value in it, ie transform it to a string ZVAL because of default string type.
Yep, forcing it to be boolean like ->BindValue('bool_param', false, PDO::PARAM_BOOL); works.
Just I want do not care at all about param data types as driver know expected types better than me.
-
D.