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.
(번역 : 기본적으로 스크립트에 의해 열려진 모든 데이터베이스 연결은 실행시간중 사용자에 의해 명시적으로 닫히거나, 스크립트의 종료시점에서 자동적으로 해제됩니다.)
AMDbest
12년 전
감사합니다.
12년 전
메모리를 비우거나 연결을 종료는 특별히 큰 데이터나 오랜 실행시간이 아니면 별 상관 없습니다^^
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5230 | 13년 전 | 3064 | ||
| 5229 | 13년 전 | 569 | ||
| 5228 | 13년 전 | 612 | ||
| 5227 | 13년 전 | 716 | ||
| 5226 | 13년 전 | 9172 | ||
| 5225 | 13년 전 | 2185 | ||
| 5224 | 13년 전 | 2599 | ||
| 5223 | 13년 전 | 2567 | ||
| 5222 | 13년 전 | 3130 | ||
| 5221 |
visualp
|
13년 전 | 716 | |
| 5220 |
|
13년 전 | 750 | |
| 5219 | 13년 전 | 4646 | ||
| 5218 |
|
13년 전 | 681 | |
| 5217 |
크라이스트
|
13년 전 | 1368 | |
| 5216 | 13년 전 | 1223 | ||
| 5215 | 13년 전 | 1241 | ||
| 5214 | 13년 전 | 1112 | ||
| 5213 | 13년 전 | 649 | ||
| 5212 | 13년 전 | 1339 | ||
| 5211 | 13년 전 | 734 | ||
| 5210 |
visualp
|
13년 전 | 1452 | |
| 5209 |
visualp
|
13년 전 | 1085 | |
| 5208 |
mammoth
|
13년 전 | 728 | |
| 5207 | 13년 전 | 2109 | ||
| 5206 | 13년 전 | 1077 | ||
| 5205 | 13년 전 | 693 | ||
| 5204 |
|
13년 전 | 2262 | |
| 5203 | 13년 전 | 1175 | ||
| 5202 | 13년 전 | 1193 | ||
| 5201 |
kastel
|
13년 전 | 1355 | |
| 5200 | 13년 전 | 1065 | ||
| 5199 | 13년 전 | 561 | ||
| 5198 | 13년 전 | 627 | ||
| 5197 | 13년 전 | 1563 | ||
| 5196 | 13년 전 | 775 | ||
| 5195 | 13년 전 | 1791 | ||
| 5194 | 13년 전 | 1293 | ||
| 5193 | 13년 전 | 606 | ||
| 5192 | 13년 전 | 4052 | ||
| 5191 | 13년 전 | 730 | ||
| 5190 |
|
13년 전 | 1850 | |
| 5189 | 13년 전 | 1171 | ||
| 5188 | 13년 전 | 1543 | ||
| 5187 |
믹스디자인
|
13년 전 | 806 | |
| 5186 |
|
13년 전 | 2382 | |
| 5185 | 13년 전 | 1431 | ||
| 5184 | 13년 전 | 889 | ||
| 5183 | 13년 전 | 1403 | ||
| 5182 | 13년 전 | 682 | ||
| 5181 | 13년 전 | 713 | ||
| 5180 |
프리온관리자
|
13년 전 | 716 | |
| 5179 | 13년 전 | 984 | ||
| 5178 | 13년 전 | 648 | ||
| 5177 | 13년 전 | 571 | ||
| 5176 | 13년 전 | 681 | ||
| 5175 | 13년 전 | 1402 | ||
| 5174 | 13년 전 | 852 | ||
| 5173 | 13년 전 | 594 | ||
| 5172 |
|
13년 전 | 565 | |
| 5171 | 13년 전 | 904 | ||
| 5170 |
KhanSu
|
13년 전 | 694 | |
| 5169 | 13년 전 | 2159 | ||
| 5168 | 13년 전 | 1487 | ||
| 5167 |
sir24
|
13년 전 | 680 | |
| 5166 | 13년 전 | 1744 | ||
| 5165 | 13년 전 | 727 | ||
| 5164 | 13년 전 | 1650 | ||
| 5163 |
|
13년 전 | 991 | |
| 5162 |
곰도리푸우
|
13년 전 | 4089 | |
| 5161 |
UltraUCC
|
13년 전 | 1227 | |
| 5160 |
|
13년 전 | 884 | |
| 5159 |
그런듯아닌듯
|
13년 전 | 544 | |
| 5158 |
|
13년 전 | 518 | |
| 5157 | 13년 전 | 1652 | ||
| 5156 | 13년 전 | 1153 | ||
| 5155 | 13년 전 | 2633 | ||
| 5154 | 13년 전 | 786 | ||
| 5153 | 13년 전 | 783 | ||
| 5152 |
|
13년 전 | 623 | |
| 5151 | 13년 전 | 827 | ||
| 5150 |
senseme
|
13년 전 | 551 | |
| 5149 |
워드앤코드
|
13년 전 | 1002 | |
| 5148 | 13년 전 | 693 | ||
| 5147 |
프로프리랜서
|
13년 전 | 902 | |
| 5146 | 13년 전 | 2395 | ||
| 5145 |
투코아미디어
|
13년 전 | 1492 | |
| 5144 |
there007
|
13년 전 | 1503 | |
| 5143 | 13년 전 | 1366 | ||
| 5142 | 13년 전 | 2090 | ||
| 5141 |
silky
|
13년 전 | 761 | |
| 5140 |
silky
|
13년 전 | 632 | |
| 5139 |
silky
|
13년 전 | 1973 | |
| 5138 |
silky
|
13년 전 | 569 | |
| 5137 |
silky
|
13년 전 | 595 | |
| 5136 |
silky
|
13년 전 | 880 | |
| 5135 |
silky
|
13년 전 | 617 | |
| 5134 |
silky
|
13년 전 | 468 | |
| 5133 |
|
13년 전 | 830 | |
| 5132 |
복이219
|
13년 전 | 971 | |
| 5131 |
바부바부팅이
|
13년 전 | 999 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기