Bug #80892 [Opn]: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
Edit report at https://bugs.php.net/bug.php?id=80892&edit=1
ID: 80892
User updated by: benjamin dot morel at gmail dot com
Reported by: benjamin dot morel at gmail dot com
Summary: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
Status: Open
Type: Bug
Package: PDO PgSQL
Operating System: Linux
PHP Version: 8.0.3
Block user comment: N
Private report: N
New Comment:
Sorry, typo. Should read:
> should respect PDO::PARAM_INT just like the mysql driver does.
Previous Comments:
------------------------------------------------------------------------
[2021-03-21 14:10:45] benjamin dot morel at gmail dot com
Description:
------------
As reported on https://externals.io/message/113521
The test script below fails because the pgsql driver seems to treat everything as PARAM_STR, despite
being explicitly requested to bind the value as PARAM_INT; the "?" placeholder is
therefore replaced with the string '4326' instead of the integer 4326.
The problem is, in PostGIS, the ST_Transform() function has different signatures with different
behaviours depending on whether the second parameter is an integer or a string.
As far as I can see, because of this issue, there is no way to pass an actual integer to a function
without using explicit, PostgreSQL-specific CAST syntax.
I believe this is a bug and the pgsql driver should respect PDO::PARAM_STR just like the mysql
driver does.
Test script:
---------------
$pdo = new PDO('pgsql:host=localhost;port=5432', 'postgres',
'postgres');
$statement = $pdo->prepare("
SELECT ST_AsText(
ST_Transform(
ST_GeomFromText('POINT(0 0)', 2154),
?
)
)
");
$statement->bindValue(1, 4326, PDO::PARAM_INT);
$statement->execute();
Expected result:
----------------
POINT(...)
Actual result:
--------------
PDOException: SQLSTATE[XX000]: Internal error: 7 ERROR: could not parse proj string '4326'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80892&edit=1
Thread (8 messages)