开发者

Is there a function for closing a mysql prepared statement with PDO?

开发者 https://www.devze.com 2023-02-25 01:15 出处:网络
In mysqli prepared statements there ismysqli_stmt::close() (Closes a prepared statement): $stmt->close();

In mysqli prepared statements there ismysqli_stmt::close() (Closes a prepared statement):

$stmt->close();

I have searched php.net and the web and cannot find an alternative for PDO.

Is this possible?

And what are the benefits of using it at the en开发者_如何转开发d of each of your scripts?

I understand that,

$connection = null;

closes the connection to mysql, but what about closing the query?


To free the result set you can apply basic PHP way.

If you are returning the results with PDOStatement::fetchAll() then you would need to unset() the variable to clear it:

$variable = $stmt->fetchAll();

unset($variable);
// or:
$variable = null; 

Or PDOStatement::closeCursor() (Closes the cursor, enabling the statement to be executed again.) may be helpful:

$success = $stmt->closeCursor();
0

精彩评论

暂无评论...
验证码 换一张
取 消