Bug #79568 [Opn->Dup]: No exception when more PDO parameters passed than needed

From: Date: Wed, 06 May 2020 08:31:27 +0000
Subject: Bug #79568 [Opn->Dup]: No exception when more PDO parameters passed than needed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226936@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79568&edit=1 ID: 79568 Updated by: cmb@php.net Reported by: thomas dot wleight at googlemail dot com Summary: No exception when more PDO parameters passed than needed -Status: Open +Status: Duplicate Type: Bug Package: PDO MySQL Operating System: Debian 9 PHP Version: 7.3.17 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Duplicate of bug #77490. Previous Comments: ------------------------------------------------------------------------ [2020-05-05 21:36:02] thomas dot wleight at googlemail dot com "$pdo_parameters = [ 1, 2, 3 ];" can be removed from the code. but keep this one: "$stmt->execute( [ 1, 2, 3 ] );" ------------------------------------------------------------------------ [2020-05-05 21:33:26] thomas dot wleight at googlemail dot com Description: ------------ If array "$pdo_parameters" contains only 1 element then everything works as expected and I receive a result. However when "$pdo_parameters" contains more than one I don't receive any results at all without any exception message. PHP errors are active, but I don't see any PDO error message. Passing more PDO parameters than needed should result in a PDO error. Test script: --------------- // db credentials $dbhost = "localhost"; $dbuser = "user"; $dbpass = "password"; $dbname = "database"; // pdo $dsn = "mysql:host=".$dbhost.";dbname=".$dbname.";charset=utf8"; $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false ]; $pdo = new PDO($dsn, $dbuser, $dbpass, $options); $sql = "SELECT * FROM foo WHERE bar > ?"; $pdo_parameters = [ 1, 2, 3 ]; $stmt = $pdo->prepare( $sql ); // PDO exception should be thrown here $stmt->execute( [ 1, 2, 3 ] ); Expected result: ---------------- Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number in /tmp/test:18 Stack trace: #0 /tmp/test.php(18): PDOStatement->execute(Array) #1 {main} thrown in /tmp/test.php on line 18 Actual result: -------------- no error ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79568&edit=1

« previous php.bugs (#226936) next »