Bug #80521 [Opn]: PDO parameter in nested SQLs for derived tables

From: Date: Tue, 15 Dec 2020 21:14:41 +0000
Subject: Bug #80521 [Opn]: PDO parameter in nested SQLs for derived tables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231106@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 User updated by: delmar dot delmar at gmail dot com Reported by: delmar dot delmar at gmail dot com Summary: PDO parameter in nested SQLs for derived tables Status: Open Type: Bug Package: PDO Firebird Operating System: Windows Pro 20H2 PHP Version: 8.0.0 Block user comment: N Private report: N New Comment: 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 _ Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#231106) next »