| Rob Hamilton 2006-03-27, 6:57 pm |
| Hi
I am current trying to migrate an existing system using MySQLi to use=20
PDO and I have a quick question with regards to Prepared Statements.=20
Essentially I'd like to replicate the Prepared Statement functionality=20
of PDO using MySQLi so that I can gradually update all the required=20
pages to use similar function calls, and then swap everything over in=20
one go rather than spending ages on a big rewrite.
Using PDO you can pass parameters as an array which are bound to the=20
query. Something like:
$stmt =3D $pdo->prepare("SELECT * FROM Blah WHERE foo =3D ?");
$params =3D 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=20
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=20
functions, and if so how?
I know is's possible to call these functions with something like:
$stmt =3D $db->prepare("SELECT * FROM Blah WHERE foo =3D ?");
$paramTypes =3D "s";
$params =3D array("SomeValue");
$stmt->bind_param($paramTypes, $params[0]);
But it seems you cannot pass the array itself using the '&' operator.
Cheers
Rob Hamilton
--=20
________________________________________
___________
Play 100s of games for FREE! http://games.mail.com/
|