Bug #80445 [Com]: Using float bind parameter returns weird error
| From: | sadd221s at proton dot me | Date: | Sat, 17 Dec 2022 07:50:50 +0000 |
| Subject: | Bug #80445 [Com]: Using float bind parameter returns weird error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-243171@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80445&edit=1
ID: 80445
Comment by: sadd221s at proton dot me
Reported by: domen at jollydeck dot com
Summary: Using float bind parameter returns weird error
Status: Re-Opened
Type: Bug
Package: PDO MySQL
Operating System: Windows, CentOS
PHP Version: 7.4.13
Block user comment: N
Private report: N
New Comment:
JavaScript
When it comes to building a business, front-end development is a crucial element. It ensures that
users interact with your website directly. It also creates a professional user experience. If you
want your website to be successful, you need to consider hiring a professional JavaScript front-end
developer.
Front-end developers develop the functionality of your web site, including playing videos and
filling out forms. These developers make use of JavaScript, CSS and RESTful services. In addition,
you will need a good knowledge of SEO, cross-browser testing, device testing and web performance
optimization.
Front-end development is crucial because of the increased number of devices that are used. A strong
front-end can lead to a large amount of online sales and repeat clients.
Front-end developers often use three programming languages - HTML, CSS and JavaScript. They can make
sure that the user interface is intuitive and pleasing to the eye. They can also develop code for
environments where the browser engine is not available. Welcome to
(https://northell.design/services/front-end-development-services).github.com for more infromation.
As the number of mobile devices rises, websites are becoming increasingly mobile-friendly. These
websites have to be designed in a way that can change the layout depending on the size of the
screen. In addition, they need to be responsive.
In addition, front-end developers can use frameworks to streamline development. These frameworks
provide pre-written standard functions and ready-made code. They are also crucial in the creation of
page structures. They also help with repetitive tasks.
Previous Comments:
------------------------------------------------------------------------
[2020-11-30 20:26:04] cmb@php.net
Ah, okay, that makes sense. :)
------------------------------------------------------------------------
[2020-11-30 16:41:12] domen at jollydeck dot com
MySQL bug: https://bugs.mysql.com/bug.php?id=101806
------------------------------------------------------------------------
[2020-11-30 13:33:39] domen at jollydeck dot com
Hi, I've stripped the original query of unnecessary stuff so that bug report could be as simple
as possible and to avoid wasting your time.
Real use case is this: we have a table of "weights" which influence some application
logic. After each user action this weight is multiplied by some factor, rounded and limited to lower
and upper bound. This could be achieved by retrieving value, doing calculations in PHP and then
updating value in table, but "simple" expression GREATEST(LEAST(ROUND(
field *
?), ?), ?) does the job and also avoids any table locking that is needed between retrieving and
updating the value. I've put word "simple" in quotes because expression has now
become GREATEST(LEAST(ROUND(field * CAST(? AS FLOAT)), CAST(? AS UNSIGNED)), CAST(? AS
UNSIGNED)) so that is works with stringified numeric bound parameters. I know PDO::PARAM_INT exists,
but this is legacy application.
------------------------------------------------------------------------
[2020-11-30 13:13:02] cmb@php.net
> $pdo->query("CREATE TABLE test
> (field INT NOT NULL) ENGINE=InnoDB");
> $stmt = $pdo->prepare("UPDATE test SET
> field = 100 * ?");
This looks plain wrong to me. Why don't you do the calculation in
PHP, and send an integer in the first place? And if it is about
monetary calculations with floats, you likely have bigger issues
than this query[1].
[1] <http://www.floating-point-gui.de/>
------------------------------------------------------------------------
[2020-11-30 07:26:17] requinix@php.net
I wouldn't hold my breath on that MySQL bug...
Reopening because there is one easy fix we could make that should address the problem: change the
error message. Perhaps dropping the data type and just saying "Invalid format".
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=80445
--
Edit this bug report at https://bugs.php.net/bug.php?id=80445&edit=1