Bug #80521 [Ver->Csd]: Parameters with underscores no longer recognized
| From: | cmb@php.net | Date: | Wed, 16 Dec 2020 19:07:00 +0000 |
| Subject: | Bug #80521 [Ver->Csd]: Parameters with underscores no longer recognized | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231126@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80521&edit=1
ID: 80521
Updated by: cmb@php.net
Reported by: delmar dot delmar at gmail dot com
Summary: Parameters with underscores no longer recognized
-Status: Verified
+Status: Closed
Type: Bug
Package: PDO Firebird
Operating System: Windows Pro 20H2
PHP Version: 8.0.0
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1860ef22eba4fed1e360482cfde32b3bfa16fcc5
Log: Fix #80521: Parameters with underscores no longer recognized
Previous Comments:
------------------------------------------------------------------------
[2020-12-15 22:32:44] cmb@php.net
I think this is due to an accidental change:
<https://github.com/php/php-src/pull/4920/files#r543735101>.
------------------------------------------------------------------------
[2020-12-15 21:14:41] delmar dot delmar at gmail dot com
In new tests, I noticed that the PHP 8.0.0 Firebird PDO does not accept _ in the SQL statement
parameter. When removing the _ from the parameter, the code works. However, in previous versions,
like 7.4.x I could use _ without problems.
If the goal is really not to accept _ in the named parameters, then this post could be closed.
Otherwise, the post could remain open.
However, it is necessary to refactor all legacy SQL code where there are parameters named using _
------------------------------------------------------------------------
[2020-12-15 20:43:27] levim@php.net
Contents of the pastebin:
<?php
$sql = ' SELECT MAT.CODIGO, MAT.COD_CURSO, MAT.CURSO FROM
(SELECT M.CODIGO, M.COD_CURSO, C.CURSO FROM
(SELECT CODIGO, COD_CURSO FROM MATRICULA WHERE COD_ALUNO = :PCOD_ALUNO) AS M
LEFT OUTER JOIN CURSO C ON M.COD_CURSO = C.CODIGO
UNION
SELECT ME.CODIGO, ME.COD_CURSO, C.CURSO FROM
(SELECT CODIGO, COD_CURSO FROM MATRICULAEJA WHERE COD_ALUNO = :PCOD_ALUNO_EJA)
AS ME
LEFT OUTER JOIN CURSO C ON ME.COD_CURSO = C.CODIGO) AS MAT
ORDER BY MAT.CURSO';
?>
------------------------------------------------------------------------
[2020-12-15 20:37:48] delmar dot delmar at gmail dot com
Description:
------------
The sample code works in version 7.4.12. After upgrading to PHP 8.0.0 it stopped working.
The error message is: object (PDOException) # 3 (8) {["message": protected] => string
(118) "SQLSTATE [HY000]: General error: -104 Dynamic SQL Error SQL error code = -104 Token
unknown ...
PHP does not recognize the parameter COD_ALUNO =: PCOD_ALUNO in nested SQLs for derived tables
(select from select).
When setting an integer for the COD_ALUNO field everything works.
https://firebirdsql.org/refdocs/langrefupd21-select.html#langrefupd21-derived-tables
Test script:
---------------
https://pastebin.com/1n32Yct4
Expected result:
----------------
As JSON
[{"CODIGO":"2118","COD_CURSO":"3","CURSO":"EDUCA\u00c7\u00c3O
DE JOVENS E
ADULTOS"},{"CODIGO":"977","COD_CURSO":"1","CURSO":"ENSINO
FUNDAMENTAL"},{"CODIGO":"2808","COD_CURSO":"1","CURSO":"ENSINO
FUNDAMENTAL"},{"CODIGO":"6555","COD_CURSO":"1","CURSO":"ENSINO
FUNDAMENTAL"}]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80521&edit=1