From: mark dot 2391 at blueyonder dot co dot uk Operating system: Debian GNU/Linux PHP version: 5.1.6 PHP Bug Type: Feature/Change Request Bug description: Permit parameters in execute()
Description: ------------ I want to convert to MySqli from PDO's MySql driver as I'm hitting a known bug in PDO that isn't getting fixed and I figure MySqli would be faster anyway. However, MySqli appears to be restrictive when compared to PDO in its insistence that I use bind_params(). PDO allows the alternative to pass Mysql parameters as an array to its execute() method. My Mysql parameters are passed to me as an array in my code. I do not know a way in PHP of passing an array of these parameters to MySQLi while it insists on using bind_params which in turn insists on a fixed list of named variables. As I say, PDO copes with this as it's execute() method offers the alternative choice while params to MySqli's execute() are marked as void, and so it seems to me impossible to implement my Data Access Service layer (which manages DB access on similar lines to the PHP SDO extension) with Mysqli at the moment unless I completely lose the advantage of prepared statements. The code below hopefully illustrates the kind of usage I need (and as I say, PDO allows). Perhaps there is a workaround I have not thought of. Thanks in advance for any comments/tips, Mark Reproduce code: --------------- <?php // I propose this change to the mysqli_stmt_execute() syntax allowing me to do something like the following: // bool mysqli_stmt_execute ( mysqli_stmt stmt [string types, array input_parameters] ) $dbh = new mysqli("localhost", "my_user", "my_password", "world"); $sql = 'INSERT INTO TableA VALUES (?, ?)'; $mysqlParamsStringTypes = 'is'; $mysqlParams = array('1', 'a'); $myDasStmt = new MyDasStmt($dbh, $sql, $mysqlParamsStringTypes); $myDasStmt->execute($mysqlParams); class MyDasStmt { protected $mysqlParamsStringTypes; protected $stmt; public function __construct($dbh, $sql, $mysqlParamsStringTypes) { $this->stmt = $dbh->stmt_init(); $this->stmt->prepare($sql); } public function execute(array $mysqlParams) { $this->stmt->execute($this->mysqlParamsStringTypes, $mysqlParams); // ... } } ?> Expected result: ---------------- N/A Actual result: -------------- N/A -- Edit bug report at http://bugs.php.net/?id=39235&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39235&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39235&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39235&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39235&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39235&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39235&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39235&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39235&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39235&r=support Expected behavior: http://bugs.php.net/fix.php?id=39235&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39235&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39235&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39235&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39235&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39235&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39235&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39235&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39235&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39235&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39235&r=mysqlcfg