mysql connect 해제 관련
function db_connect() {
$result = new mysqli('localhost', '****', '****', '****');
if (!$result) {
throw new Exception('Could not connect to database server');
} else {
return $result;
}
}
$conn = db_connect();
$result = $conn->query("update tour_popup
set title = '".$title."'
,memo = '".$memo."'
,open_yn = '".$open_yn."'
,width = ".$width."
,height = ".$height."
,pos_x = ".$pos_x."
,pos_y = ".$pos_y."
where idx = ".$idx." ");
이렇게 실행하고 난 후에
이 구문을 반드시 써줘야되나요?
원랜 반드시 써줘야 리소스 낭비를 막는다고 알고있는데, 전에 어떤분이
$conn->query 이런식으로 사용하면
실행 후 굳이 해제 구문을 안써도 자동으로 해제된다고 들은것 같아서요.
$result = new mysqli('localhost', '****', '****', '****');
if (!$result) {
throw new Exception('Could not connect to database server');
} else {
return $result;
}
}
$conn = db_connect();
$result = $conn->query("update tour_popup
set title = '".$title."'
,memo = '".$memo."'
,open_yn = '".$open_yn."'
,width = ".$width."
,height = ".$height."
,pos_x = ".$pos_x."
,pos_y = ".$pos_y."
where idx = ".$idx." ");
이렇게 실행하고 난 후에
/* 결과를 파괴하고 사용된 메모리를 풀어준다
*/
$result->close();
}
$result->close();
}
/* 접속 닫기 */
$mysqli->close();
$mysqli->close();
이 구문을 반드시 써줘야되나요?
원랜 반드시 써줘야 리소스 낭비를 막는다고 알고있는데, 전에 어떤분이
$conn->query 이런식으로 사용하면
실행 후 굳이 해제 구문을 안써도 자동으로 해제된다고 들은것 같아서요.
댓글 3개
12년 전
php의 실행이 종료되면 mysqli 연결도 끊어집니다.
http://php.net/manual/en/mysqli.quickstart.connections.php
By default, every database connection opened by a script is either explicitly closed by the user during runtime or released automatically at the end of the script.
(번역 : 기본적으로 스크립트에 의해 열려진 모든 데이터베이스 연결은 실행시간중 사용자에 의해 명시적으로 닫히거나, 스크립트의 종료시점에서 자동적으로 해제됩니다.)
http://php.net/manual/en/mysqli.quickstart.connections.php
By default, every database connection opened by a script is either explicitly closed by the user during runtime or released automatically at the end of the script.
(번역 : 기본적으로 스크립트에 의해 열려진 모든 데이터베이스 연결은 실행시간중 사용자에 의해 명시적으로 닫히거나, 스크립트의 종료시점에서 자동적으로 해제됩니다.)
게시판 목록
자유게시판
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 |
|
2주 전 | 52 | |
| 199718 |
|
2주 전 | 31 | |
| 199717 | 1개월 전 | 29 | ||
| 199716 |
느긋한카키쿠키
|
1개월 전 | 19 | |
| 199715 |
현대적인무질서한까마귀
|
1개월 전 | 23 | |
| 199714 | 1개월 전 | 33 | ||
| 199713 | 1개월 전 | 41 | ||
| 199712 | 1개월 전 | 303 | ||
| 199711 |
안졸리니졸리니
|
1개월 전 | 150 | |
| 199710 |
|
1개월 전 | 164 | |
| 199709 |
|
1개월 전 | 96 | |
| 199708 | 1개월 전 | 110 | ||
| 199707 | 2개월 전 | 246 | ||
| 199706 | 2개월 전 | 47 | ||
| 199705 | 2개월 전 | 31 | ||
| 199704 | 2개월 전 | 55 | ||
| 199703 | 2개월 전 | 60 | ||
| 199702 | 2개월 전 | 104 | ||
| 199701 | 2개월 전 | 114 | ||
| 199700 | 2개월 전 | 86 | ||
| 199699 | 2개월 전 | 92 | ||
| 199698 | 2개월 전 | 139 | ||
| 199697 | 2개월 전 | 103 | ||
| 199696 |
|
2개월 전 | 252 | |
| 199695 | 2개월 전 | 96 | ||
| 199694 | 2개월 전 | 126 | ||
| 199693 | 2개월 전 | 194 | ||
| 199692 | 2개월 전 | 205 | ||
| 199691 |
|
2개월 전 | 180 | |
| 199690 | 2개월 전 | 265 | ||
| 199689 | 2개월 전 | 165 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기