本文整理匯總了PHP中Install::remove_remarks方法的典型用法代碼示例。如果您正苦於以下問題:PHP Install::remove_remarks方法的具體用法?PHP Install::remove_remarks怎麽用?PHP Install::remove_remarks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Install
的用法示例。
在下文中一共展示了Install::remove_remarks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Step3
public function Step3()
{
// Have we been told to create a new database
$this->db_create = Kit::GetParam('db_create', _POST, _INT);
// Check all parameters have been specified
$this->db_admin_user = Kit::GetParam('admin_username', _POST, _PASSWORD);
$this->db_admin_pass = Kit::GetParam('admin_password', _POST, _PASSWORD);
$this->new_db_host = Kit::GetParam('host', _POST, _STRING);
$this->new_db_user = Kit::GetParam('db_username', _POST, _PASSWORD);
$this->new_db_pass = Kit::GetParam('db_password', _POST, _PASSWORD);
$this->new_db_name = Kit::GetParam('db_name', _POST, _PASSWORD);
$this->existing_db_host = Kit::GetParam('existing_host', _POST, _STRING);
$this->existing_db_user = Kit::GetParam('existing_db_username', _POST, _PASSWORD);
$this->existing_db_pass = Kit::GetParam('existing_db_password', _POST, _PASSWORD);
$this->existing_db_name = Kit::GetParam('existing_db_name', _POST, _PASSWORD);
// If an administrator user name / password has been specified then we should create a new DB
if ($this->db_create == 1) {
// Check details for a new database
if ($this->new_db_host == '') {
throw new Exception(__('Please provide a database host. This is usually localhost.'));
}
if ($this->new_db_user == '') {
throw new Exception(__('Please provide a user for the new database.'));
}
if ($this->new_db_pass == '') {
throw new Exception(__('Please provide a password for the new database.'));
}
if ($this->new_db_name == '') {
throw new Exception(__('Please provide a name for the new database.'));
}
if ($this->db_admin_user == '') {
throw new Exception(__('Please provide an admin user name.'));
}
// Try to create the new database
// Try and connect using these details and create the new database
try {
$dbh = PDOConnect::connect($this->new_db_host, $this->db_admin_user, $this->db_admin_pass);
} catch (Exception $e) {
throw new Exception(sprintf(__('Could not connect to MySQL with the administrator details. Please check and try again. Error Message = [%s]'), $e->getMessage()));
}
// Try to create the new database
try {
$dbh = PDOConnect::init();
$dbh->exec(sprintf('CREATE DATABASE `%s`', $this->new_db_name));
} catch (Exception $e) {
throw new Exception(sprintf(__('Could not create a new database with the administrator details [%s]. Please check and try again. Error Message = [%s]'), $this->db_admin_user, $e->getMessage()));
}
// Try to create the new user
try {
$dbh = PDOConnect::init();
// Create the user and grant privileges
if ($this->new_db_host == 'localhost') {
$dbh->exec(sprintf('GRANT ALL PRIVILEGES ON `%s`.* to %s@%s IDENTIFIED BY %s', $this->new_db_name, $dbh->quote($this->new_db_user), $dbh->quote($this->new_db_host), $dbh->quote($this->new_db_pass)));
} else {
$dbh->exec(sprintf("GRANT ALL PRIVILEGES ON `%s`.* to %s@%% IDENTIFIED BY %s", $this->new_db_name, $dbh->quote($this->new_db_user), $dbh->quote($this->new_db_pass)));
}
// Flush
$dbh->exec('FLUSH PRIVILEGES');
} catch (Exception $e) {
throw new Exception(sprintf(__('Could not create a new user with the administrator details. Please check and try again. Error Message = [%s]'), $e->getMessage()));
}
// Set our DB details
$this->existing_db_host = $this->new_db_host;
$this->existing_db_user = $this->new_db_user;
$this->existing_db_pass = $this->new_db_pass;
$this->existing_db_name = $this->new_db_name;
// Close the connection
PDOConnect::close();
} else {
// Check details for a new database
if ($this->existing_db_host == '') {
throw new Exception(__('Please provide a database host. This is usually localhost.'));
}
if ($this->existing_db_user == '') {
throw new Exception(__('Please provide a user for the existing database.'));
}
if ($this->existing_db_pass == '') {
throw new Exception(__('Please provide a password for the existing database.'));
}
if ($this->existing_db_name == '') {
throw new Exception(__('Please provide a name for the existing database.'));
}
}
// Try and make a connection with this database
try {
$dbh = PDOConnect::connect($this->existing_db_host, $this->existing_db_user, $this->existing_db_pass, $this->existing_db_name);
} catch (Exception $e) {
throw new Exception(sprintf(__('Could not connect to MySQL with the administrator details. Please check and try again. Error Message = [%s]'), $e->getMessage()));
}
// We should have a database that we can access and populate with our tables.
$sql_files = array('structure.sql', 'data.sql');
$sqlStatementCount = 0;
$sql_file = '';
$sql = '';
try {
$dbh = PDOConnect::init();
foreach ($sql_files as $filename) {
$delimiter = ';';
$sql_file = @file_get_contents('install/master/' . $filename);
$sql_file = Install::remove_remarks($sql_file);
//.........這裏部分代碼省略.........
示例2: Step3
public function Step3()
{
Kit::ClassLoader('install');
set_time_limit(0);
$fault = false;
$fault_string = '';
foreach ($_POST as $key => $post) {
// $key should be like 1-2, 1-3 etc
// Split $key on - character.
$parts = explode('-', $key);
if (count($parts) == 2) {
$step_num = 'Step' . $parts[0];
include_once 'install/database/' . $parts[0] . '.php';
$response = $_SESSION[$step_num]->ValidateQuestion($parts[1], $post);
if (!$response == true) {
// The upgrade routine for this step wasn't happy.
$fault = true;
$fault_string .= $response . "<br />\n";
}
}
}
if ($fault) {
throw new Exception($fault_string);
}
$doBackup = Kit::GetParam('doBackup', $_POST, _CHECKBOX);
if ($doBackup == 0) {
throw new Exception(__('You MUST have a valid database backup to continue. Please take and verify a backup and upgrade again.'));
}
$sql_file = '';
$sql = '';
$i = 0;
// Now loop over the entire upgrade. Run the SQLs and PHP interleaved.
try {
$dbh = PDOConnect::init();
//$dbh->beginTransaction();
for ($i = $_SESSION['upgradeFrom'] + 1; $i <= $_SESSION['upgradeTo']; $i++) {
if (file_exists('install/database/' . $i . '.sql')) {
$delimiter = ';';
$sql_file = @file_get_contents('install/database/' . $i . '.sql');
$sql_file = Install::remove_remarks($sql_file);
$sql_file = Install::split_sql_file($sql_file, $delimiter);
foreach ($sql_file as $sql) {
$dbh->exec($sql);
}
}
if (file_exists('install/database/' . $i . '.php')) {
$stepName = 'Step' . $i;
if (!$_SESSION[$stepName]->Boot()) {
throw new Exception(__('Failed with %s', $stepName));
}
}
}
//$dbh->commit();
} catch (Exception $e) {
//$dbh->rollBack();
throw new Exception(sprintf(__('An error occurred running the upgrade. Please take a screen shot of this page and seek help. Statement number: %d. Error Message = [%s]. File = [%s]. SQL = [%s].'), $i, $e->getMessage(), $sql_file, $sql));
}
// Install files
Media::installAllModuleFiles();
// Delete install
if (!unlink('install.php')) {
$formFields[] = FormManager::AddMessage(__("Unable to delete install.php. Please ensure the webserver has permission to unlink this file and retry"));
}
$formFields[] = FormManager::AddMessage(__('The upgrade was a success!'));
// Return a rendered form
Theme::Set('form_fields', $formFields);
return Theme::RenderReturn('form_render');
}