本文整理匯總了PHP中DBAccess::setDbHost方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBAccess::setDbHost方法的具體用法?PHP DBAccess::setDbHost怎麽用?PHP DBAccess::setDbHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBAccess
的用法示例。
在下文中一共展示了DBAccess::setDbHost方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
/**
* @param string $url
* @param string $url2
*/
public function index($url = "", $url2 = "")
{
if (Tools::isPost('submitDBConfigBtn')) {
$db_provider = 'mysql';
$db_host = Tools::post('db_host');
$db_username = Tools::post('db_username');
$db_password = Tools::post('db_password');
$db_name = Tools::post('db_name');
$dbError = false;
$DB = NewADOConnection($db_provider);
try {
$DB->Connect($db_host, $db_username, $db_password, $db_name);
} catch (ErrorException $e) {
$dbError = true;
}
$result = $DB->Execute("Show tables;");
$errorMsg = $DB->ErrorMsg();
if ($result === false || $dbError === true || $errorMsg != "") {
FlashSession::setFlash('error', $errorMsg);
} else {
$DB->Close();
$dbAccess = new DBAccess();
$dbAccess->setDbUsername($db_username);
$dbAccess->setDbPassword($db_password);
$dbAccess->setDbHost($db_host);
$dbAccess->setDbName($db_name);
Session::set('dbAccess', $dbAccess);
Session::set('dbConfigured', true);
if ($url != "") {
$url = $url2 == "" ? $url2 : $url . "/" . $url2;
Tools::redirect($url);
} else {
Tools::redirect('home');
}
}
}
$this->view->render('dbconfig/index');
}