Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PDO Open and Close Connection

Posted on 2016-07-27
1
Medium Priority
?
544 Views
Last Modified: 2016-07-28
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?
0
Comment
Question by:rgranlund
1 Comment
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 41731974
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:
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question