本文整理匯總了PHP中CSession::db_link方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSession::db_link方法的具體用法?PHP CSession::db_link怎麽用?PHP CSession::db_link使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CSession
的用法示例。
在下文中一共展示了CSession::db_link方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initialise
static function initialise($ConfigFile)
{
if ($initialised) {
return;
}
// Run this only once!
include $ConfigFile;
$host = $conf['database_host'];
$db = $conf['database_name'];
$user = $conf['database_login'];
$pass = $conf['database_pass'];
CSession::$session_timeout = $conf['session_timeout_sec'];
// connect to mysql and open database
CSession::$db_link = mysql_connect($host, $user, $pass) or die("Couldn't connect to the database");
@mysql_select_db($db, CSession::$db_link) or die("Unable to select database");
// // Create a db connection using PDO. Should migrate everything over to use PDO.
// CSession::$pdo_dbh = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
// Connection using mysqli for the newer code. Should move all mysql code to mysqli!
mysqli_report(MYSQLI_REPORT_STRICT);
try {
CSession::$dbh = new mysqli($host, $user, $pass, $db);
if (CSession::$dbh->connect_errno) {
die("FAILED TO CONNECT TO THE DB. ERROR: " . CSession::$dbh->connect_error);
exit;
}
} catch (mysqli_sql_exception $e) {
die("FAILED TO CONNECT TO THE DB. ERROR: " . $e->getMessage());
}
}