$link = mysql_connect('localhost', 'mysql_user', 'mysql_password', true);Trong nhiều trường hợp cần tạo lại conn ví dụ như thời gian thực thi script quá lâu
nhất là chạy ở cmd
function _connect() {
$this->link = mysql_connect( $this->host, $this->user, $this->pass) or die( mysql_error( $this->link));
mysql_select_db( $this->db_name, $this->link);
}
Khi code chạy đến dòng mysql_select_db thì báo lỗi mysql has gone away mặc dù trên đã có lời gọi hàm kết nối mới
Nguyên nhân là mặc dù sử dụng lời gọi hàm kết nối nhưng kết nối mới ko được tạo ra
If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The new_link parameter modifies this behavior and makes mysql_connect() always open a new link, even if mysql_connect() was called before with the same parameters. In SQL safe mode, this parameter is ignored.
No comments:
Post a Comment