Php中关闭数据库链接的时候注意
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Php中关闭数据库链接的时候注意
没有错
require_once ("../config.php");
require_once (_CMSDIR . "/class/admin.class.php");
require_once (_CMSDIR . "/class/systemType.class.php");
require_once (_CMSDIR . "/class/member.class.php");
$admin = new admin ( );
if ($_SERVER ['REQUEST_METHOD'] == "POST") {
//判断会员id是不是存在
$member = new member ( );
$member->search ( "id=" . $_POST ["mId"] );
if ($member->countnum < 1) {
$member->close();
echo "";
exit ();
}
//判断用户名是不是已经被注册了
$thisResult = $admin->getCount ( "aName='" . $_POST ["aName"] . "'" );
if ($thisResult > 0) {
echo "";
$admin->close ();
exit ();
}
//添加记录
$admin->add ();
$member->close();
$admin->close ();
turntopage ( "admin_add.php", "您已经成功添加一条记录!",3);
}
//从用户权限组里查找全部数据
$admintype = new systemtype ( );
$types = $admintype->getall ( " 1=1" );
include ("templets/admin_add.html");
$admin->close ();
$admintype->close ();
?>
下面的就有错了
require_once ("../config.php");
require_once (_CMSDIR . "/class/admin.class.php");
require_once (_CMSDIR . "/class/systemType.class.php");
require_once (_CMSDIR . "/class/member.class.php");
$admin = new admin ( );
if ($_SERVER ['REQUEST_METHOD'] == "POST") {
//判断会员id是不是存在
$member = new member ( );
$member->search ( "id=" . $_POST ["mId"] );
$member->close ();
if ($member->countnum < 1) {
echo "";
exit ();
}
//判断用户名是不是已经被注册了
$thisResult = $admin->getCount ( "aName='" . $_POST ["aName"] . "'" );
if ($thisResult > 0) {
echo "";
$admin->close ();
exit ();
}
//添加记录
$admin->add ();
$admin->close ();
turntopage ( "admin_add.php", "您已经成功添加一条记录!", 300 );
}
//从用户权限组里查找全部数据
$admintype = new systemtype ( );
$types = $admintype->getall ( " 1=1" );
include ("templets/admin_add.html");
$admin->close ();
$admintype->close ();
?>
总结:上面的区别是一个数据关闭的较早一个较晚,所以关闭的时候一定要注意实时的关闭,和适时的关闭。