MySQLi Prepared Statements

From: Date: Mon, 27 Mar 2006 17:37:40 +0000
Subject: MySQLi Prepared Statements
Groups: php.db 
Request: Send a blank email to php-db+get-41610@lists.php.net to get a copy of this message
Hi I am current trying to migrate an existing system using MySQLi to use PDO and I have a quick question with regards to Prepared Statements. Essentially I'd like to replicate the Prepared Statement functionality of PDO using MySQLi so that I can gradually update all the required pages to use similar function calls, and then swap everything over in one go rather than spending ages on a big rewrite. Using PDO you can pass parameters as an array which are bound to the query. Something like: $stmt = $pdo->prepare("SELECT * FROM Blah WHERE foo = ?"); $params = array("SomeValue"); $stmt->execute($params) The PDO function "execute" takes 1 parameter which is an array. There are similar functions in MySQLi such as bind_param and bind_result of which one of the parameters is of type "mixed &var1 [, mixed &...]". Is it possible to construct an array of this type and pass it to these functions, and if so how? I know is's possible to call these functions with something like: $stmt = $db->prepare("SELECT * FROM Blah WHERE foo = ?"); $paramTypes = "s"; $params = array("SomeValue"); $stmt->bind_param($paramTypes, $params[0]); But it seems you cannot pass the array itself using the '&' operator. Cheers Rob Hamilton -- ___________________________________________________ Play 100s of games for FREE! http://games.mail.com/

« previous php.db (#41610) next »