10/10/2018, 10:40
hỏi về mysql_close
hàm này có yêu cầu bắt buộc phải gọi không. mình đọc trong w3school nó nói như vầy, khi kết thúc script, connection tự động đóng
http://www.w3schools.com/PHP/func_mysql_close.asp
Tip: Using mysql_close() isn't required, as non-persistent connections are automatically closed at the end of the script
http://www.w3schools.com/PHP/func_mysql_close.asp
Tip: Using mysql_close() isn't required, as non-persistent connections are automatically closed at the end of the script
Bài liên quan
Cú pháp: mysql_close($biến kết nối);
Tuy nhiên, nếu cần, bạn cũng có thể close nó khi cần để giải tỏa bớt áp lực cho DB server.
Ví dụ đoạm code PHP kết nối lấy dữ liệu về rồi nhưng còn công đoạn xử lý khá lâu. Khi đó phải chờ công đoạn xử lý hoàn tất thì mysql mới tự đóng, mysql server phải mất thêm một thời gian. Nếu bạn đóng liền thì kết nối đó sẽ đóng liền, thời gian đó để dành cho server xử lý những kết nối khác.