fetch_all or fetch_assoc MySQLi statement
is it possible to use the fetch_all()
, fetch_assoc()
etc. from the the MySQLi_Result
class with a prepared statement from the MySQLi_STMT class?
I've done it using the query()
method in the Mysqli class (and by escaping trough mysqli_real_escape_string()
), but not using 开发者_开发百科statements with binding parameters.
I'm considering using PDO
thanks!
First of all, if you are using PDO, you will not be using the mysqli_*
function : those are two different APIs.
Using PDO, you'll be able to use the PDOStatement->fetchAll
method, if you want to fetch all results from a resultset.
Else, you'll have to use PDOStatement->fetch
, or any other fetch*()
method, in a loop, to iterate over the resultset.
If using prepared statements with MySQLi, you will apparently not have an instance of MySQLi_Result
-- which means you'll have to work with mysqli_stmt::fetch
over your resultset, looping by yourself.
精彩评论