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

From: Date: Tue, 15 Dec 2020 20:43:27 +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-231105@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: levim@php.net 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: 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'; ?> Previous Comments: ------------------------------------------------------------------------ [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 (#231105) next »