Jump to content

Archived

This topic is now archived and is closed to further replies.

manmanman

Does die automatically terminate mySQL connections?

Recommended Posts

Does die automatically terminate mySQL connections? Also, how can I run operations, such as delete unactivated users 48 hours after registration, without using a cron job?

Share this post


Link to post
Share on other sites
1) I'm pretty sure all database connections terminate on the end of script execution. I believe mysql_close() is for if you want to close the connection before the script ends.

2) You could run a query every time somebody enters your site that will look like this: [code]$time = time()-(3600*24*48);
@mysql_query("DELETE FROM users WHERE activated=0 AND registration_date<{$time}");[/code]

Share this post


Link to post
Share on other sites
If you use a non persistent connection to the MySQL database, you dont need to add mysql_close() before die or exit.

mysql_connect()  <-- non persitant connection
mysql_pconnect() <-- persistant connection

If you use a persistant connection then you will need to add mysql_close() [b]before[/b] die or exit to close your persistant connection.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.