Req #48431 [Opn->Wfx]: Support PDO::PARAM_STMT

From: Date: Fri, 09 Jul 2021 13:21:52 +0000
Subject: Req #48431 [Opn->Wfx]: Support PDO::PARAM_STMT
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234935@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48431&edit=1 ID: 48431 Updated by: cmb@php.net Reported by: candrews at integralblue dot com Summary: Support PDO::PARAM_STMT -Status: Open +Status: Wont fix Type: Feature/Change Request Package: PDO related Operating System: * PHP Version: 5.2.9 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: PARAM_STMT sounds like a failed attempt at this point; PARAM_ARRAY might be more reasonable, but anyhow, both features would require an RFC. Given that there were no further comments on this ticket for almost ten years, I'm closing as WONTFIX. If anybody is still looking for this fearture, please pursue the RFC process[1]. [1] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2011-12-01 06:34:00] ssufficool@php.net I believe the correct syntax would be: <?php $sth = $dbh->prepare("SELECT * FROM users JOIN :usernames as mytab on users.name = mytab.username"); $sth2 = $dbh2->execute("select username, userid, accesslevel from permissions where accesslevel='admin'") $sth->bindParam(":usernames", $sth2, PDO::PARAM_STMT); $sth->execute(); ?> PDO::PARAM_ARRAY would make more sense for an associative array argument, which could be used in the same way. An example prepared statement for either case would be: SELECT * FROM users JOIN ( SELECT 'user1' as username, 1 as userid, 'admin' as accesslevel UNION ALL SELECT 'user5' as username, 5 as userid, 'admin' as accesslevel ) as mytab on users.name = mytab.username ------------------------------------------------------------------------ [2009-05-29 20:08:26] candrews at integralblue dot com Description: ------------ According to the PDO constants page at http://us3.php.net/manual/en/pdo.constants.php , PDO::PARAM_STMT "Represents a recordset type. Not currently supported by any drivers." It would be nice if PDO supported this type for all drivers in that don't directly support it using emulation, and for drivers do, using the driver implementation (just like how all the other prepared statement parameter types work). Reproduce code: --------------- Right now, implementing a prepared statement query involving arrays is (I believe) impossible. <?php $sth = $dbh->prepare('SELECT * FROM users WHERE username in :usernames); $sth->bindParam(":usernames", array("alice","bob","dave"), PDO::PARAM_STMT); $sth->execute(); ?> That would be very nice to be able to do - and I believe that is the correct syntax. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=48431&edit=1

« previous php.bugs (#234935) next »