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

前端 未结 1 1566
旧巷少年郎
旧巷少年郎 2021-01-19 16:15

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

$stmt->close();

I have searched php.net and th

1条回答
  •  一整个雨季
    2021-01-19 17:03

    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 讨论(0)
提交回复
热议问题