本文整理汇总了PHP中CSession::dbh方法的典型用法代码示例。如果您正苦于以下问题:PHP CSession::dbh方法的具体用法?PHP CSession::dbh怎么用?PHP CSession::dbh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSession
的用法示例。
在下文中一共展示了CSession::dbh方法的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());
}
}