本文整理汇总了PHP中Vtiger_Util_Helper::checkDbUTF8Support方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Util_Helper::checkDbUTF8Support方法的具体用法?PHP Vtiger_Util_Helper::checkDbUTF8Support怎么用?PHP Vtiger_Util_Helper::checkDbUTF8Support使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Util_Helper
的用法示例。
在下文中一共展示了Vtiger_Util_Helper::checkDbUTF8Support方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDbConnection
/**
* Function checks the database connection
* @param <String> $db_type
* @param <String> $db_hostname
* @param <String> $db_username
* @param <String> $db_password
* @param <String> $db_name
* @param <String> $create_db
* @param <String> $create_utf8_db
* @param <String> $root_user
* @param <String> $root_password
* @return <Array>
*/
public static function checkDbConnection($db_type, $db_hostname, $db_username, $db_password, $db_name, $create_db = false, $create_utf8_db = true, $root_user = '', $root_password = '')
{
$dbCheckResult = array();
$db_type_status = false;
// is there a db type?
$db_server_status = false;
// does the db server connection exist?
$db_creation_failed = false;
// did we try to create a database and fail?
$db_exist_status = false;
// does the database exist?
$db_utf8_support = false;
// does the database support utf8?
//Checking for database connection parameters
if ($db_type) {
$conn =& NewADOConnection($db_type);
$db_type_status = true;
if (@$conn->Connect($db_hostname, $db_username, $db_password)) {
$db_server_status = true;
$serverInfo = $conn->ServerInfo();
if (self::isMySQL($db_type)) {
$mysql_server_version = self::getMySQLVersion($serverInfo);
}
if ($create_db) {
// drop the current database if it exists
$dropdb_conn =& NewADOConnection($db_type);
if (@$dropdb_conn->Connect($db_hostname, $root_user, $root_password, $db_name)) {
$query = "DROP DATABASE " . $db_name;
$dropdb_conn->Execute($query);
$dropdb_conn->Close();
}
// create the new database
$db_creation_failed = true;
$createdb_conn =& NewADOConnection($db_type);
if (@$createdb_conn->Connect($db_hostname, $root_user, $root_password)) {
$query = "CREATE DATABASE " . $db_name;
if ($create_utf8_db == 'true') {
if (self::isMySQL($db_type)) {
$query .= " DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci";
}
$db_utf8_support = true;
}
if ($createdb_conn->Execute($query)) {
$db_creation_failed = false;
}
$createdb_conn->Close();
}
}
if (@$conn->Connect($db_hostname, $db_username, $db_password, $db_name)) {
$db_exist_status = true;
if (!$db_utf8_support) {
$db_utf8_support = Vtiger_Util_Helper::checkDbUTF8Support($conn);
}
}
$conn->Close();
}
}
$dbCheckResult['db_utf8_support'] = $db_utf8_support;
$error_msg = '';
$error_msg_info = '';
if (!$db_type_status || !$db_server_status) {
$error_msg = getTranslatedString('ERR_DATABASE_CONNECTION_FAILED', 'Install') . '. ' . getTranslatedString('ERR_INVALID_MYSQL_PARAMETERS', 'Install');
$error_msg_info = getTranslatedString('MSG_LIST_REASONS', 'Install') . ':<br>
- ' . getTranslatedString('MSG_DB_PARAMETERS_INVALID', 'Install') . '
- ' . getTranslatedString('MSG_DB_USER_NOT_AUTHORIZED', 'Install');
} elseif (self::isMySQL($db_type) && $mysql_server_version < 4.1) {
$error_msg = $mysql_server_version . ' -> ' . getTranslatedString('ERR_INVALID_MYSQL_VERSION', 'Install');
} elseif ($db_creation_failed) {
$error_msg = getTranslatedString('ERR_UNABLE_CREATE_DATABASE', 'Install') . ' ' . $db_name;
$error_msg_info = getTranslatedString('MSG_DB_ROOT_USER_NOT_AUTHORIZED', 'Install');
} elseif (!$db_exist_status) {
$error_msg = $db_name . ' -> ' . getTranslatedString('ERR_DB_NOT_FOUND', 'Install');
} else {
$dbCheckResult['flag'] = true;
return $dbCheckResult;
}
$dbCheckResult['flag'] = false;
$dbCheckResult['error_msg'] = $error_msg;
$dbCheckResult['error_msg_info'] = $error_msg_info;
return $dbCheckResult;
}