Re: [RFC] deprecate PDO::PARAM_NULL

php.internals

Dorin Marcoci

9 years ago
> I would agree that NULL is not a type and the constant shouldn't have > been there in the first place, but I think it could be a bit too late now.
Raising an warning for first 1-2 years with later removal sounds OK. Also docs should be updated to mark this constant deprecated. Yes, null is a state, not a type. ->bindValue('Foo', PDO::PARAM_NULL) is awesome. So it should be deprecated and removed.

Lester Caine

9 years ago
On 18/05/17 09:15, Dorin Marcoci wrote:
> Yes, null is a state, not a type. ->bindValue('Foo', PDO::PARAM_NULL) is > awesome. > So it should be deprecated and removed.
? One of the reasons for using 'prepare' is to set up a query which can be run several times and some of those passes may require that one of the parameters IS null. Easy enough with the array passed to Execute, but more difficult if you have used the PDO parameter handling. In my book being able to flag a parameter as 'NULL' for a pass is just as important as supplying a value, so while yes NULL is a state, it is also a valid value for a parameter.
-- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

Marco Pivetta

9 years ago
On Thu, May 18, 2017 at 11:38 AM, Lester Caine <lester@lsces.co.uk> wrote:
> On 18/05/17 09:15, Dorin Marcoci wrote: > > Yes, null is a state, not a type. ->bindValue('Foo', PDO::PARAM_NULL) is > > awesome. > > So it should be deprecated and removed. > > ? One of the reasons for using 'prepare' is to set up a query which can > be run several times and some of those passes may require that one of > the parameters IS null. Easy enough with the array passed to Execute, > but more difficult if you have used the PDO parameter handling. In my > book being able to flag a parameter as 'NULL' for a pass is just as > important as supplying a value, so while yes NULL is a state, it is also > a valid value for a parameter. >
You can bind `NULL` pretty much with any PDO type - PDO::PARAM_NULL is not needed to do so. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/

Lester Caine

9 years ago
On 18/05/17 10:43, Marco Pivetta wrote:
> On Thu, May 18, 2017 at 11:38 AM, Lester Caine <lester@lsces.co.uk> wrote: > >> On 18/05/17 09:15, Dorin Marcoci wrote: >>> Yes, null is a state, not a type. ->bindValue('Foo', PDO::PARAM_NULL) is >>> awesome. >>> So it should be deprecated and removed. >> ? One of the reasons for using 'prepare' is to set up a query which can >> be run several times and some of those passes may require that one of >> the parameters IS null. Easy enough with the array passed to Execute, >> but more difficult if you have used the PDO parameter handling. In my >> book being able to flag a parameter as 'NULL' for a pass is just as >> important as supplying a value, so while yes NULL is a state, it is also >> a valid value for a parameter. >> > You can bind `NULL` pretty much with any PDO type - PDO::PARAM_NULL is not > needed to do so.
Except that PDO::PARAM_NULL removes the need to assign a particular type to a parameter when the underlying field has the option to be of different types. While the interface may default to returning a string, PARAM_STR is not always the right thing to use. PARAM_AUTO is just as wrong in PDO which is SUPPOSED to return the same set of values which ever database engine is used. PARAM_FLOAT is similarly introducing the potential that different databases will give different results for both read and write. The whole point of PDO used to be that one could simply cahnge the selected driver and not have to change any code but all of the recent changes seem to have thrown that out of the windows?
-- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk