Jump to content


Photo

Does die automatically terminate mySQL connections?


  • Please log in to reply
2 replies to this topic

#1 manmanman

manmanman
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 18 September 2006 - 03:49 AM

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?

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 18 September 2006 - 06:04 AM

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:
$time = time()-(3600*24*48);
@mysql_query("DELETE FROM users WHERE activated=0 AND registration_date<{$time}");


#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 18 September 2006 - 02:16 PM

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() before die or exit to close your persistant connection.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users