Re: PDO::PARAM_DOUBLE

From: Date: Thu, 08 Dec 2016 14:53:08 +0000
Subject: Re: PDO::PARAM_DOUBLE
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-97341@lists.php.net to get a copy of this message
Hi Adam, On 07/12/2016 23:37, Adam Baratz wrote: > For decimal, double wouldn't be the correct type anyway, as it could > cause loss of precision. > > > Sure, agree the name is imprecise. "Double" is mainly relevant to zvals. It's not about naming. Double is relevant both to PHP and SQL and is a floating point type. On the other hand, decimal/numeric fields should be represented as strings as they are fixed point/precision, which is something we don't have in stock php. In fact bcmath uses strings too. > > Is there a reason PDO::PARAM_DOUBLE doesn't exist? > > I don't know if there's am historical reason. I think it should be > there, but to be honest, I'm not sure it's worth the effort at this > point. > > > Say more on why you don't think there'd be a payoff? I'd think that it > would be worth taking the (I'm guessing) max. 3 days involved to add > missing functionality to a widely-used extension. I think it would be the biggest PDO API change to date and we should be very careful. Lots of #ifdefs for pecl pdo_* developers to add, if they want to keep their extensions backwards compatible. My biggest worry is its potential misuse for decimal fields. I know this isn't reason enough for denying an improvement, but there are already too many people mistakenly using double for currency data and monetary calculations... That said, I think this more than anything else requires a proper RFC and discussion. Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/

« previous php.internals (#97341) next »