floridaflatlander Posted August 10, 2012 Share Posted August 10, 2012 I've been wrting this are the bottom of a script header("Location: $home/index.php"); mysqli_free_result($r); mysqli_close($dbc); exit(); I was wondering can exit() remove a querys overhead and close a database connection also, meaning this is the same thing. header("Location: $home/index.php"); exit(); php.net says exit() "Terminates execution of the script". So maybe it closes the db connection(a script) but leaves a query's overhead?? Link to comment https://forums.phpfreaks.com/topic/266909-does-exit-remove-a-querys-overhead-close-a-database-connection/ Share on other sites More sharing options...
Christian F. Posted August 10, 2012 Share Posted August 10, 2012 There is absolutely no need to ever use the free_result () or close () methods/functions on SQL connections, simply because PHP handles all of this automatically when the script ends. This happens both on normal execution end (getting to the end of the file) and when you kill off the script early (via die ()). This has nothing to do with the functions you use, but is a standard part of the PHP interpreter's clean up routines. So no overhead left, at all. Link to comment https://forums.phpfreaks.com/topic/266909-does-exit-remove-a-querys-overhead-close-a-database-connection/#findComment-1368360 Share on other sites More sharing options...
Adam Posted August 10, 2012 Share Posted August 10, 2012 Never mind. Link to comment https://forums.phpfreaks.com/topic/266909-does-exit-remove-a-querys-overhead-close-a-database-connection/#findComment-1368364 Share on other sites More sharing options...
floridaflatlander Posted August 10, 2012 Author Share Posted August 10, 2012 thanks, it does save time Link to comment https://forums.phpfreaks.com/topic/266909-does-exit-remove-a-querys-overhead-close-a-database-connection/#findComment-1368466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.