WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any method to close connection similar to mysql_close() for wpdb in wordpress? Is it not necessary to close connection for global wpdb?

share|improve this question
up vote 5 down vote accepted

There is no explicit method. It stores link identifier in $wpdb->dbh field, so I guess you could use mysql_close() on it.

Why do you need it btw? If you want to reuse $wpdb it is better to create separate wpdb object instead.

share|improve this answer
means it is not needed to close global wpdb connection???? – Brij Feb 1 '11 at 9:38
@Brij unless I am missing something it should be closed automatically when page finishes loading and PHP ends execution. – Rarst Feb 1 '11 at 9:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.