Using MYSQLI_USE_RESULT with prepared statements

Viewed 35

How can I use

$stmt = $db->query($sqlString, MYSQLI_USE_RESULT);

But with prepare function? I need it, because I am using bind params, but now I need to also use MYSQLI_USE_RESULT for big data. I need something like this:

$stmt = $db->prepare($sqlString, MYSQLI_USE_RESULT);
1 Answers

With prepared statements this is the default, from the manual (emphasis mine)...

Prepared statements return unbuffered result sets by default. The results of the statement are not implicitly fetched and transferred from the server to the client for client-side buffering. The result set takes server resources until all results have been fetched by the client. Thus it is recommended to consume results timely. If a client fails to fetch all results or the client closes the statement before having fetched all data, the data has to be fetched implicitly by mysqli.

Related