conn = mysql_pc"/> conn = mysql_pc">

首頁  >  文章  >  後端開發  >  PHP长时间连接数据库促成mysql has gone away

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

WBOY
WBOY原創
2016-06-13 12:36:58793瀏覽

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");
}

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn