本文整理匯總了PHP中DBC::closeConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBC::closeConnection方法的具體用法?PHP DBC::closeConnection怎麽用?PHP DBC::closeConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBC
的用法示例。
在下文中一共展示了DBC::closeConnection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: DBC
require_once SYS_PATH . 'dbConfig.php';
$dbc = new DBC(0);
// 0 defines database id in dbConfig.php
$db = $dbc->getConnection();
$db->exec("SET CHARACTER SET utf8");
try {
$sql = "SELECT id FROM `users` WHERE `key`= ? AND `pass`= ?";
$stmt = $db->prepare($sql);
$stmt->execute(array($key, $value));
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$rows = $stmt->fetchAll();
if (empty($rows)) {
header('HTTP/1.1 401 Unauthorized.', TRUE, 401);
echo 'You are not authorised to access this page.';
exit(1);
// EXIT_ERROR
}
$dbc->closeConnection();
} catch (PDOException $e) {
header('HTTP/1.1 401 Unauthorized.', TRUE, 401);
echo 'You are not authorised to access this page.';
exit(1);
// EXIT_ERROR
}
} else {
header('HTTP/1.1 401 Unauthorized.', TRUE, 401);
echo 'You are not authorised to access this page.';
exit(1);
// EXIT_ERROR
}
}