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년 전
메모리를 비우거나 연결을 종료는 특별히 큰 데이터나 오랜 실행시간이 아니면 별 상관 없습니다^^
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6830 |
112211dd
|
11년 전 | 797 | |
| 6829 |
진짜다진짜가나타남
|
11년 전 | 1219 | |
| 6828 | 11년 전 | 829 | ||
| 6827 |
봉보로봉봉
|
11년 전 | 919 | |
| 6826 |
jinion
|
11년 전 | 832 | |
| 6825 | 11년 전 | 809 | ||
| 6824 |
yunkiri486
|
11년 전 | 730 | |
| 6823 |
2donggalbi
|
11년 전 | 859 | |
| 6822 | 11년 전 | 860 | ||
| 6821 | 11년 전 | 805 | ||
| 6820 | 11년 전 | 3112 | ||
| 6819 | 11년 전 | 1261 | ||
| 6818 | 11년 전 | 521 | ||
| 6817 |
|
11년 전 | 618 | |
| 6816 | 11년 전 | 2086 | ||
| 6815 | 11년 전 | 1221 | ||
| 6814 | 11년 전 | 872 | ||
| 6813 | 11년 전 | 621 | ||
| 6812 |
|
11년 전 | 990 | |
| 6811 | 11년 전 | 593 | ||
| 6810 | 11년 전 | 1547 | ||
| 6809 |
낚시가좋아
|
11년 전 | 1052 | |
| 6808 | 11년 전 | 449 | ||
| 6807 | 11년 전 | 780 | ||
| 6806 |
Unhappy
|
11년 전 | 1784 | |
| 6805 | 11년 전 | 1619 | ||
| 6804 | 11년 전 | 1137 | ||
| 6803 | 11년 전 | 579 | ||
| 6802 |
asdfg
|
11년 전 | 1149 | |
| 6801 |
아트귀농인
|
11년 전 | 511 | |
| 6800 | 11년 전 | 2566 | ||
| 6799 | 11년 전 | 1361 | ||
| 6798 | 11년 전 | 1477 | ||
| 6797 | 11년 전 | 634 | ||
| 6796 |
purple63
|
11년 전 | 435 | |
| 6795 | 11년 전 | 2641 | ||
| 6794 |
커네드커네드
|
11년 전 | 965 | |
| 6793 | 11년 전 | 415 | ||
| 6792 | 11년 전 | 2506 | ||
| 6791 | 11년 전 | 533 | ||
| 6790 | 11년 전 | 2267 | ||
| 6789 |
리아빌리티
|
11년 전 | 3107 | |
| 6788 | 11년 전 | 1348 | ||
| 6787 | 11년 전 | 684 | ||
| 6786 | 11년 전 | 395 | ||
| 6785 | 11년 전 | 725 | ||
| 6784 |
|
11년 전 | 855 | |
| 6783 | 11년 전 | 593 | ||
| 6782 | 11년 전 | 3660 | ||
| 6781 |
리아빌리티
|
11년 전 | 500 | |
| 6780 | 11년 전 | 542 | ||
| 6779 | 11년 전 | 494 | ||
| 6778 | 11년 전 | 4704 | ||
| 6777 |
바보온달123
|
11년 전 | 625 | |
| 6776 | 11년 전 | 936 | ||
| 6775 | 11년 전 | 738 | ||
| 6774 |
DANet
|
11년 전 | 647 | |
| 6773 | 11년 전 | 1562 | ||
| 6772 | 11년 전 | 1367 | ||
| 6771 | 11년 전 | 624 | ||
| 6770 | 11년 전 | 1164 | ||
| 6769 | 11년 전 | 962 | ||
| 6768 | 11년 전 | 696 | ||
| 6767 | 11년 전 | 591 | ||
| 6766 | 11년 전 | 1272 | ||
| 6765 |
크림나이트
|
11년 전 | 1006 | |
| 6764 | 11년 전 | 1558 | ||
| 6763 | 11년 전 | 2615 | ||
| 6762 | 11년 전 | 545 | ||
| 6761 |
|
11년 전 | 794 | |
| 6760 |
|
11년 전 | 721 | |
| 6759 | 11년 전 | 3354 | ||
| 6758 | 11년 전 | 1014 | ||
| 6757 | 11년 전 | 1276 | ||
| 6756 | 11년 전 | 898 | ||
| 6755 |
|
11년 전 | 576 | |
| 6754 |
|
11년 전 | 725 | |
| 6753 |
|
11년 전 | 1396 | |
| 6752 | 11년 전 | 613 | ||
| 6751 |
|
11년 전 | 657 | |
| 6750 |
|
11년 전 | 2031 | |
| 6749 | 11년 전 | 1222 | ||
| 6748 |
|
11년 전 | 1126 | |
| 6747 | 11년 전 | 1177 | ||
| 6746 | 11년 전 | 842 | ||
| 6745 |
|
11년 전 | 917 | |
| 6744 | 11년 전 | 857 | ||
| 6743 | 11년 전 | 1298 | ||
| 6742 | 11년 전 | 543 | ||
| 6741 |
Abilityarch
|
11년 전 | 614 | |
| 6740 | 11년 전 | 662 | ||
| 6739 |
leewin20
|
11년 전 | 1242 | |
| 6738 | 11년 전 | 514 | ||
| 6737 | 11년 전 | 1221 | ||
| 6736 | 11년 전 | 1263 | ||
| 6735 | 11년 전 | 558 | ||
| 6734 | 11년 전 | 1291 | ||
| 6733 |
RipperTNT
|
11년 전 | 1847 | |
| 6732 |
|
11년 전 | 1341 | |
| 6731 |
|
11년 전 | 1399 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기