How to correctly free a PDO instance
for example:
$db = new PD开发者_开发百科O();
// some code using $db here
// and next, i want to free this var and close all connection and so on
$db = NULL; // or how correctly?
Is that correct way to free all SQL results and connections?
you could do that, but often not necessary. if created in a function and no other vars are using it, $db will release its contents when it goes out of scope (usually at the end of the function). if $db is a global, it will be released when the script ends.
精彩评论