NYCPHP Meetup

NYPHP.org

[nycphp-talk] When to close a mysql connection

Cliff Hirsch cliff at pinestream.com
Mon Jul 2 07:13:31 EDT 2007


Hey, just an aside for everyone.

I always had my DB close statement as the last line of my scripts. Then one
day, everything stopped working properly. Why?

Seems right -- when you're done you're done -- right? Wrong. PHP does plenty
of "stuff" after your script is finished.

Remember -- if you use database-base sessions, use session_write_close
BEFORE you close your DB connection. And you probably want to use
session_write_close before any header redirects as well to eliminate timing
issues.

Cliff





More information about the talk mailing list