conn = mysql_pc"/> conn = mysql_pc">

Heim  >  Artikel  >  Backend-Entwicklung  >  PHP长时间连接数据库促成mysql has gone away

PHP长时间连接数据库促成mysql has gone away

WBOY
WBOYOriginal
2016-06-13 12:36:58793Durchsuche

PHP长时间连接数据库造成mysql has gone away
public function connect() {
if ($this->conn == "pconn") {
//永久链接
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
} else {
//即使链接
$this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
}

if (!mysql_select_db($this->db_database, $this->conn)) {
if ($this->show_error) {
$this->show_error("数据库不可用:", $this->db_database);
}
}
mysql_query("SET NAMES $this->coding");
}

上面贴的是数据库连接的写法,请问怎么写能做到不出现错误呢?还有其他的方法吗?

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn