WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#20178 new enhancement

wpdb class : provide a disconnect / connect to db functions

Reported by: arena Owned by: arena
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.4
Component: Database Keywords: close
Focuses: Cc:

Description

some hosts automatically disconnect mysql after a short while.
I think it could be interesting to have in wpdb a disconnect and connect functions.

Change History (5)

comment:1 ocean902 years ago

  • Summary changed from enhancement : wpdb class : provide a disconnect / connect to db functions to wpdb class : provide a disconnect / connect to db functions

Related: #5932

comment:2 arena2 years ago

Hi ocean90

the code i am currently using

class data_base
{
	function mysql_disconnect()
	{
		global $wpdb;
		mysql_close($wpdb->dbh);
	}

	function mysql_connect()
	{
		global $wpdb;
		$wpdb->__construct(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
	}
}

but still have some "mysql_real_escape_string(): nn is not a valid MySQL- Link resource" on some webhosts after disconnecting/connecting !

comment:3 nacin3 months ago

  • Component changed from General to Database

comment:4 pento3 months ago

  • Keywords close added; dev-feedback removed

Unless there's another use case for this, I'm inclined to close this ticket. The reported bug (hosts automatically disconnecting MySQL) will be fixed by #5932.

comment:5 arena3 months ago

Not sure to close this ticket is a good option.
At least wordpress to privide an api in fixing #5932.
Some plugins may use it ...

Note: See TracTickets for help on using tickets.