• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 981
  • Last Modified:

PDO Open and Close Connection

When you run an INSERT Query in PHP PDO and you start a DB connection:
$dsn = "mysql:host=$db_host;dbname=$db_name";

Should you then close it?
1 Solution
Ray PaseurCommented:
Nope. You never need to close it.  The script termination routines will close it for you at the right time, which is the end of the script.

Examples in the article here:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now