当前位置: 首页>>代码示例>>PHP>>正文


PHP install_cli_database函数代码示例

本文整理汇总了PHP中install_cli_database函数的典型用法代码示例。如果您正苦于以下问题:PHP install_cli_database函数的具体用法?PHP install_cli_database怎么用?PHP install_cli_database使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了install_cli_database函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install_site

 /**
  * Installs a site using $CFG->dataroot and $CFG->prefix
  * @throws coding_exception
  * @return void
  */
 public static function install_site()
 {
     global $DB;
     if (!defined('BEHAT_UTIL')) {
         throw new coding_exception('This method can be only used by Behat CLI tool');
     }
     // New dataroot.
     self::reset_dataroot();
     $options = array();
     $options['adminuser'] = 'admin';
     $options['adminpass'] = 'admin';
     $options['fullname'] = 'Acceptance test site';
     install_cli_database($options, false);
     // Update admin user info.
     $user = $DB->get_record('user', array('username' => 'admin'));
     $user->email = 'moodle@moodlemoodle.com';
     $user->firstname = 'Admin';
     $user->lastname = 'User';
     $user->city = 'Perth';
     $user->country = 'AU';
     $DB->update_record('user', $user);
     // Sets maximum debug level.
     set_config('debug', DEBUG_DEVELOPER);
     set_config('debugdisplay', true);
     // Keeps the current version of database and dataroot.
     self::store_versions_hash();
     // Stores the database contents for fast reset.
     self::store_database_state();
 }
开发者ID:Burick,项目名称:moodle,代码行数:34,代码来源:util.php

示例2: install_site

 /**
  * Installs a site using $CFG->dataroot and $CFG->prefix
  * @throws coding_exception
  * @return void
  */
 public static function install_site()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/user/lib.php';
     if (!defined('BEHAT_UTIL')) {
         throw new coding_exception('This method can be only used by Behat CLI tool');
     }
     // New dataroot.
     self::reset_dataroot();
     $options = array();
     $options['adminuser'] = 'admin';
     $options['adminpass'] = 'admin';
     $options['fullname'] = self::BEHATSITENAME;
     $options['shortname'] = self::BEHATSITENAME;
     install_cli_database($options, false);
     $frontpagesummary = new admin_setting_special_frontpagedesc();
     $frontpagesummary->write_setting(self::BEHATSITENAME);
     // Update admin user info.
     $user = $DB->get_record('user', array('username' => 'admin'));
     $user->email = 'moodle@moodlemoodle.com';
     $user->firstname = 'Admin';
     $user->lastname = 'User';
     $user->city = 'Perth';
     $user->country = 'AU';
     user_update_user($user, false);
     // Disable email message processor.
     $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email'));
     // Sets maximum debug level.
     set_config('debug', DEBUG_DEVELOPER);
     set_config('debugdisplay', true);
     // Keeps the current version of database and dataroot.
     self::store_versions_hash();
     // Stores the database contents for fast reset.
     self::store_database_state();
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:40,代码来源:util.php

示例3: install_site

 /**
  * Installs a site using $CFG->dataroot and $CFG->prefix
  * @throws coding_exception
  * @return void
  */
 public static function install_site()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/user/lib.php';
     if (!defined('BEHAT_UTIL')) {
         throw new coding_exception('This method can be only used by Behat CLI tool');
     }
     $tables = $DB->get_tables(false);
     if (!empty($tables)) {
         behat_error(BEHAT_EXITCODE_INSTALLED);
     }
     // New dataroot.
     self::reset_dataroot();
     $options = array();
     $options['adminuser'] = 'admin';
     $options['adminpass'] = 'admin';
     $options['fullname'] = self::BEHATSITENAME;
     $options['shortname'] = self::BEHATSITENAME;
     install_cli_database($options, false);
     // We need to keep the installed dataroot filedir files.
     // So each time we reset the dataroot before running a test, the default files are still installed.
     self::save_original_data_files();
     $frontpagesummary = new admin_setting_special_frontpagedesc();
     $frontpagesummary->write_setting(self::BEHATSITENAME);
     // Update admin user info.
     $user = $DB->get_record('user', array('username' => 'admin'));
     $user->email = 'moodle@example.com';
     $user->firstname = 'Admin';
     $user->lastname = 'User';
     $user->city = 'Perth';
     $user->country = 'AU';
     user_update_user($user, false);
     // Disable email message processor.
     $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email'));
     // Sets maximum debug level.
     set_config('debug', DEBUG_DEVELOPER);
     set_config('debugdisplay', 1);
     // Disable some settings that are not wanted on test sites.
     set_config('noemailever', 1);
     // Enable web cron.
     set_config('cronclionly', 0);
     // Set editor autosave to high value, so as to avoid unwanted ajax.
     set_config('autosavefrequency', '604800', 'editor_atto');
     // Keeps the current version of database and dataroot.
     self::store_versions_hash();
     // Stores the database contents for fast reset.
     self::store_database_state();
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:53,代码来源:util.php

示例4: install_site

 /**
  * Install a site using $CFG->dataroot and $CFG->prefix
  *
  * @return string|bool true on success, else exception code.
  */
 public static function install_site($sitefullname = "Performance test site", $siteshortname = "Performance test site", $adminpass = "admin", $adminemail = "admin@example.com")
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/user/lib.php';
     if (!defined('PERFORMANCE_SITE_GENERATOR')) {
         util::performance_exception('This method can be only used by performance site generator.');
     }
     // If already installed, then return with error.
     $tables = $DB->get_tables(false);
     if (!empty($tables)) {
         return self::SITE_ERROR_INSTALLED;
     }
     $options = array();
     $options['adminuser'] = 'admin';
     $options['adminpass'] = $adminpass;
     $options['fullname'] = $sitefullname;
     $options['shortname'] = $siteshortname;
     install_cli_database($options, false);
     $frontpagesummary = new \admin_setting_special_frontpagedesc();
     $frontpagesummary->write_setting($sitefullname);
     // Update admin user info.
     $user = $DB->get_record('user', array('username' => 'admin'));
     $user->email = $adminemail;
     $user->firstname = 'Admin';
     $user->lastname = 'User';
     $user->city = 'Perth';
     $user->country = 'AU';
     user_update_user($user, false);
     // Disable email message processor.
     $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email'));
     // Disable some settings that are not wanted on test sites.
     set_config('noemailever', 1);
     // Enable web cron.
     set_config('cronclionly', 0);
     $CFG->dboptions = array('dbpersist' => 1);
     // Keeps the current version of components hash.
     self::store_versions_hash();
 }
开发者ID:rajeshtaneja,项目名称:moodle-performance-toolkit,代码行数:43,代码来源:installer.php

示例5: install_site

 /**
  * Perform a fresh test site installation
  *
  * Note: To be used from CLI scripts only.
  *
  * @static
  * @return void may terminate execution with exit code
  */
 public static function install_site()
 {
     global $DB, $CFG;
     if (!self::is_test_site()) {
         phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not install on non-test site!!');
     }
     if ($DB->get_tables()) {
         list($errorcode, $message) = phpunit_util::testing_ready_problem();
         if ($errorcode) {
             phpunit_bootstrap_error(PHPUNIT_EXITCODE_REINSTALL, 'Database tables already present, Moodle PHPUnit test environment can not be initialised');
         } else {
             phpunit_bootstrap_error(0, 'Moodle PHPUnit test environment is already initialised');
         }
     }
     $options = array();
     $options['adminpass'] = 'admin';
     $options['shortname'] = 'phpunit';
     $options['fullname'] = 'PHPUnit test site';
     install_cli_database($options, false);
     // Disable all logging for performance and sanity reasons.
     set_config('enabled_stores', '', 'tool_log');
     // We need to keep the installed dataroot filedir files.
     // So each time we reset the dataroot before running a test, the default files are still installed.
     self::save_original_data_files();
     // install timezone info
     $timezones = get_records_csv($CFG->libdir . '/timezone.txt', 'timezone');
     update_timezone_records($timezones);
     // Store version hash in the database and in a file.
     self::store_versions_hash();
     // Store database data and structure.
     self::store_database_state();
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:40,代码来源:util.php

示例6: install_site

 /**
  * Perform a fresh test site installation
  *
  * Note: To be used from CLI scripts only.
  *
  * @static
  * @return void may terminate execution with exit code
  */
 public static function install_site()
 {
     global $DB, $CFG;
     if (!self::is_test_site()) {
         phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not install on non-test site!!');
     }
     if ($DB->get_tables()) {
         list($errorcode, $message) = phpunit_util::testing_ready_problem();
         if ($errorcode) {
             phpunit_bootstrap_error(PHPUNIT_EXITCODE_REINSTALL, 'Database tables already present, Moodle PHPUnit test environment can not be initialised');
         } else {
             phpunit_bootstrap_error(0, 'Moodle PHPUnit test environment is already initialised');
         }
     }
     $options = array();
     $options['adminpass'] = 'admin';
     $options['shortname'] = 'phpunit';
     $options['fullname'] = 'PHPUnit test site';
     install_cli_database($options, false);
     // install timezone info
     $timezones = get_records_csv($CFG->libdir . '/timezone.txt', 'timezone');
     update_timezone_records($timezones);
     // Store version hash in the database and in a file.
     self::store_versions_hash();
     // Store database data and structure.
     self::store_database_state();
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:35,代码来源:util.php

示例7: chdir

$installlang = $CFG->lang;
// return back to original dir before executing setup.php which changes the dir again
chdir($olddir);
// We have config.php, it is a real php script from now on :-)
require $configfile;
// use selected language
$CFG->lang = $installlang;
$SESSION->lang = $CFG->lang;
require "{$CFG->dirroot}/version.php";
// Test environment first.
require_once $CFG->libdir . '/environmentlib.php';
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
    $errors = environment_get_errors($environment_results);
    cli_heading(get_string('environment', 'admin'));
    foreach ($errors as $error) {
        list($info, $report) = $error;
        echo "!! {$info} !!\n{$report}\n\n";
    }
    exit(1);
}
// Test plugin dependencies.
$failed = array();
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
    cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
    cli_error(get_string('pluginschecktodo', 'admin'));
}
install_cli_database($options, $interactive);
echo get_string('cliinstallfinished', 'install') . "\n";
exit(0);
// 0 means success
开发者ID:mongo0se,项目名称:moodle,代码行数:31,代码来源:install.php

示例8: cli_problem

            $a->dest = $CFG->dataroot . '/lang';
            cli_problem(get_string('remotedownloaderror', 'error', $a));
        }
    }
}
// switch the string_manager instance to stop using install/lang/
$CFG->early_install_lang = false;
get_string_manager(true);
require "{$CFG->dirroot}/version.php";
// Test environment first.
require_once $CFG->libdir . '/environmentlib.php';
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
    $errors = environment_get_errors($environment_results);
    cli_heading(get_string('environment', 'admin'));
    foreach ($errors as $error) {
        list($info, $report) = $error;
        echo "!! {$info} !!\n{$report}\n\n";
    }
    exit(1);
}
// Test plugin dependencies.
$failed = array();
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
    cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
    cli_error(get_string('pluginschecktodo', 'admin'));
}
install_cli_database($options, true);
echo get_string('cliinstallfinished', 'install') . "\n";
exit(0);
// 0 means success
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:install_database.php

示例9: install_site

 /**
  * Perform a fresh test site installation
  *
  * Note: To be used from CLI scripts only.
  *
  * @static
  * @return void may terminate execution with exit code
  */
 public static function install_site()
 {
     global $DB, $CFG;
     if (!self::is_test_site()) {
         phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not install on non-test site!!');
     }
     if ($DB->get_tables()) {
         list($errorcode, $message) = phpunit_util::testing_ready_problem();
         if ($errorcode) {
             phpunit_bootstrap_error(PHPUNIT_EXITCODE_REINSTALL, 'Database tables already present, Moodle PHPUnit test environment can not be initialised');
         } else {
             phpunit_bootstrap_error(0, 'Moodle PHPUnit test environment is already initialised');
         }
     }
     $options = array();
     $options['adminpass'] = 'admin';
     $options['shortname'] = 'phpunit';
     $options['fullname'] = 'PHPUnit test site';
     install_cli_database($options, false);
     // install timezone info
     $timezones = get_records_csv($CFG->libdir . '/timezone.txt', 'timezone');
     update_timezone_records($timezones);
     // add test db flag
     $hash = phpunit_util::get_version_hash();
     set_config('phpunittest', $hash);
     // store data for all tables
     $data = array();
     $structure = array();
     $tables = $DB->get_tables();
     foreach ($tables as $table) {
         $columns = $DB->get_columns($table);
         $structure[$table] = $columns;
         if (isset($columns['id']) and $columns['id']->auto_increment) {
             $data[$table] = $DB->get_records($table, array(), 'id ASC');
         } else {
             // there should not be many of these
             $data[$table] = $DB->get_records($table, array());
         }
     }
     $data = serialize($data);
     file_put_contents("{$CFG->dataroot}/phpunit/tabledata.ser", $data);
     phpunit_boostrap_fix_file_permissions("{$CFG->dataroot}/phpunit/tabledata.ser");
     $structure = serialize($structure);
     file_put_contents("{$CFG->dataroot}/phpunit/tablestructure.ser", $structure);
     phpunit_boostrap_fix_file_permissions("{$CFG->dataroot}/phpunit/tablestructure.ser");
     // hash all plugin versions - helps with very fast detection of db structure changes
     file_put_contents("{$CFG->dataroot}/phpunit/versionshash.txt", $hash);
     phpunit_boostrap_fix_file_permissions("{$CFG->dataroot}/phpunit/versionshash.txt", $hash);
 }
开发者ID:nigeli,项目名称:moodle,代码行数:57,代码来源:util.php

示例10: install_site

 /**
  * Perform a fresh test site installation
  *
  * Note: To be used from CLI scripts only.
  *
  * @static
  * @return void may terminate execution with exit code
  */
 public static function install_site()
 {
     global $DB, $CFG;
     if (!self::is_test_site()) {
         cli_error('Can not install non-test sites!!', 131);
     }
     if ($DB->get_tables()) {
         cli_error('Database tables already installed, drop the site first.', 133);
     }
     $options = array();
     $options['adminpass'] = 'admin';
     // removed later
     $options['shortname'] = 'phpunit';
     $options['fullname'] = 'PHPUnit test site';
     install_cli_database($options, false);
     // just in case remove admin password so that normal login is not possible
     $DB->set_field('user', 'password', 'not cached', array('username' => 'admin'));
     // add test db flag
     set_config('phpunittest', 'phpunittest');
     // store data for all tables
     $data = array();
     $tables = $DB->get_tables();
     foreach ($tables as $table) {
         $data[$table] = $DB->get_records($table, array());
     }
     $data = serialize($data);
     @unlink("{$CFG->dataroot}/phpunit/tabledata.ser");
     file_put_contents("{$CFG->dataroot}/phpunit/tabledata.ser", $data);
     // hash all plugin versions - helps with very fast detection of db structure changes
     $hash = phpunit_util::get_version_hash();
     @unlink("{$CFG->dataroot}/phpunit/versionshash.txt");
     file_put_contents("{$CFG->dataroot}/phpunit/versionshash.txt", $hash);
 }
开发者ID:nickread,项目名称:moodle,代码行数:41,代码来源:lib.php


注:本文中的install_cli_database函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。