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년 전
메모리를 비우거나 연결을 종료는 특별히 큰 데이터나 오랜 실행시간이 아니면 별 상관 없습니다^^
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5130 | 13년 전 | 754 | ||
| 5129 | 13년 전 | 1763 | ||
| 5128 | 13년 전 | 931 | ||
| 5127 | 13년 전 | 512 | ||
| 5126 | 13년 전 | 759 | ||
| 5125 | 13년 전 | 1367 | ||
| 5124 | 13년 전 | 837 | ||
| 5123 | 13년 전 | 474 | ||
| 5122 | 13년 전 | 1000 | ||
| 5121 |
|
13년 전 | 1383 | |
| 5120 | 13년 전 | 506 | ||
| 5119 | 13년 전 | 484 | ||
| 5118 | 13년 전 | 412 | ||
| 5117 | 13년 전 | 725 | ||
| 5116 | 13년 전 | 465 | ||
| 5115 | 13년 전 | 915 | ||
| 5114 | 13년 전 | 939 | ||
| 5113 |
cookieyou
|
13년 전 | 1352 | |
| 5112 | 13년 전 | 534 | ||
| 5111 | 13년 전 | 827 | ||
| 5110 | 13년 전 | 4441 | ||
| 5109 | 13년 전 | 1062 | ||
| 5108 | 13년 전 | 417 | ||
| 5107 | 13년 전 | 492 | ||
| 5106 | 13년 전 | 640 | ||
| 5105 | 13년 전 | 1106 | ||
| 5104 | 13년 전 | 415 | ||
| 5103 |
프로프리랜서
|
13년 전 | 1347 | |
| 5102 | 13년 전 | 1589 | ||
| 5101 | 13년 전 | 464 | ||
| 5100 | 13년 전 | 374 | ||
| 5099 | 13년 전 | 523 | ||
| 5098 | 13년 전 | 2138 | ||
| 5097 | 13년 전 | 383 | ||
| 5096 | 13년 전 | 534 | ||
| 5095 | 13년 전 | 388 | ||
| 5094 | 13년 전 | 397 | ||
| 5093 | 13년 전 | 882 | ||
| 5092 | 13년 전 | 1065 | ||
| 5091 | 13년 전 | 426 | ||
| 5090 | 13년 전 | 518 | ||
| 5089 | 13년 전 | 964 | ||
| 5088 | 13년 전 | 420 | ||
| 5087 | 13년 전 | 1175 | ||
| 5086 | 13년 전 | 1505 | ||
| 5085 |
|
13년 전 | 3943 | |
| 5084 |
alexseo
|
13년 전 | 923 | |
| 5083 | 13년 전 | 1129 | ||
| 5082 | 13년 전 | 608 | ||
| 5081 | 13년 전 | 528 | ||
| 5080 | 13년 전 | 609 | ||
| 5079 | 13년 전 | 987 | ||
| 5078 | 13년 전 | 2208 | ||
| 5077 | 13년 전 | 683 | ||
| 5076 |
몰보는거야
|
13년 전 | 1696 | |
| 5075 |
|
13년 전 | 1775 | |
| 5074 | 13년 전 | 2021 | ||
| 5073 |
|
13년 전 | 774 | |
| 5072 |
프로프리랜서
|
13년 전 | 1045 | |
| 5071 |
프로프리랜서
|
13년 전 | 767 | |
| 5070 |
프로프리랜서
|
13년 전 | 877 | |
| 5069 |
뭐먹고살지ㅠ
|
13년 전 | 790 | |
| 5068 |
danielle
|
13년 전 | 651 | |
| 5067 | 13년 전 | 760 | ||
| 5066 | 13년 전 | 835 | ||
| 5065 | 13년 전 | 909 | ||
| 5064 | 13년 전 | 1720 | ||
| 5063 | 13년 전 | 438 | ||
| 5062 | 13년 전 | 831 | ||
| 5061 | 13년 전 | 586 | ||
| 5060 | 13년 전 | 391 | ||
| 5059 |
senseme
|
13년 전 | 862 | |
| 5058 | 13년 전 | 2881 | ||
| 5057 | 13년 전 | 1938 | ||
| 5056 | 13년 전 | 1496 | ||
| 5055 | 13년 전 | 452 | ||
| 5054 |
senseme
|
13년 전 | 1072 | |
| 5053 |
senseme
|
13년 전 | 1910 | |
| 5052 |
senseme
|
13년 전 | 1038 | |
| 5051 |
senseme
|
13년 전 | 1060 | |
| 5050 |
senseme
|
13년 전 | 802 | |
| 5049 |
senseme
|
13년 전 | 990 | |
| 5048 | 13년 전 | 1994 | ||
| 5047 | 13년 전 | 497 | ||
| 5046 |
우렁찬우렁이
|
13년 전 | 886 | |
| 5045 |
크라이스트
|
13년 전 | 2162 | |
| 5044 | 13년 전 | 973 | ||
| 5043 | 13년 전 | 535 | ||
| 5042 | 13년 전 | 981 | ||
| 5041 |
|
13년 전 | 813 | |
| 5040 |
스마일라니
|
13년 전 | 880 | |
| 5039 | 13년 전 | 1152 | ||
| 5038 | 13년 전 | 1930 | ||
| 5037 | 13년 전 | 1049 | ||
| 5036 |
cookieyou
|
13년 전 | 1404 | |
| 5035 | 13년 전 | 501 | ||
| 5034 | 13년 전 | 565 | ||
| 5033 | 13년 전 | 490 | ||
| 5032 | 13년 전 | 439 | ||
| 5031 | 13년 전 | 732 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기