本文整理汇总了PHP中require_wp_db函数的典型用法代码示例。如果您正苦于以下问题:PHP require_wp_db函数的具体用法?PHP require_wp_db怎么用?PHP require_wp_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了require_wp_db函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTables
function createTables()
{
echo "start";
$query_users = "CREATE TABLE IF NOT EXISTS `datr_User` (\n `userID` INT NOT NULL ,\n `name` VARCHAR(45) NOT NULL ,\n `gender` VARCHAR(45) NOT NULL ,\n `outlook-feature` TINYINT(1) NOT NULL ,\n `mandantID` INT NOT NULL ,\n `title` VARCHAR(45) NOT NULL ,\n PRIMARY KEY (`userID`) )\nENGINE = InnoDB;\n";
$query_topics = "CREATE TABLE IF NOT EXISTS `datr_Topics` (\n `topicID` INT NOT NULL AUTO_INCREMENT ,\n `Name` VARCHAR(45) NOT NULL ,\n `template_title_long` VARCHAR(45) NULL ,\n `template_title_short` VARCHAR(45) NULL ,\n `template_description` VARCHAR(45) NULL ,\n `template_duration_min` INT NULL ,\n `content_link` VARCHAR(45) NOT NULL ,\n PRIMARY KEY (`topicID`) )\nENGINE = InnoDB;";
$query_locations = "CREATE TABLE IF NOT EXISTS `datr_Locations` (\n `locationID` INT NOT NULL AUTO_INCREMENT ,\n `name` VARCHAR(45) NOT NULL ,\n PRIMARY KEY (`locationID`) )\nENGINE = InnoDB;";
$query_addresses = "CREATE TABLE IF NOT EXISTS `datr_Addresses` (\n `address` VARCHAR(45) NULL ,\n `meeting_room` VARCHAR(45) NULL ,\n `addressID` INT NOT NULL AUTO_INCREMENT,\n `locationID` INT NOT NULL ,\n `instructionLink` VARCHAR(256) NULL ,\n `contentLink` VARCHAR(256) NULL ,\n PRIMARY KEY (`addressID`) ,\n INDEX `fk_Offline_Addresses_Locations1_idx` (`locationID` ASC) ,\n CONSTRAINT `fk_Offline_Addresses_Locations1`\n FOREIGN KEY (`locationID` )\n REFERENCES `datr_Locations` (`locationID` )\n ON DELETE CASCADE\n ON UPDATE CASCADE)\nENGINE = InnoDB;";
$query_events = "CREATE TABLE `datr_Events` ( \n `eventID` int(11) NOT NULL AUTO_INCREMENT, \n `eventType` varchar(45) NOT NULL, \n `title_long` varchar(256) NOT NULL, \n `title_short` varchar(45) NOT NULL, \n `date_time` datetime DEFAULT NULL, \n `duration_min` int(11) DEFAULT NULL, \n `invitation_text` text, \n `lecturer_name` varchar(45) DEFAULT NULL, \n `booked_participants` int(11) DEFAULT NULL, \n `max_participants` int(11) DEFAULT NULL, \n `topicID` int(11) NOT NULL, \n `mandantID` int(11) NOT NULL, \n `addressID` int(11) NOT NULL, \n `event_visible` tinyint(1) DEFAULT NULL, \n PRIMARY KEY (`eventID`), \n KEY `fk_Events_Topics1_idx` (`topicID`), \n KEY `fk_Events_Offline_Addresses_idx` (`addressID`), \n CONSTRAINT `fk_Events_Offline_Addresses` \n FOREIGN KEY (`addressID`) \n REFERENCES `datr_Addresses` (`addressID`) \n ON DELETE CASCADE \n ON UPDATE CASCADE, \n CONSTRAINT `fk_Events_Topics1` \n FOREIGN KEY (`topicID`) \n REFERENCES `datr_Topics` (`topicID`) \n ON DELETE CASCADE \n ON UPDATE CASCADE) \n ENGINE=InnoDB";
$query_User_has_Topics = "CREATE TABLE IF NOT EXISTS `datr_User_has_Topics` (\n `userID` INT NOT NULL ,\n `topicID` INT NOT NULL ,\n `current_eventID` INT NULL ,\n `last_eventID` INT NULL ,\n `repetition_frequency_days` INT NOT NULL ,\n `topic_expiry_date` DATETIME NULL ,\n `current_deadline` DATETIME NULL ,\n `last_reminded` DATETIME NULL ,\n `remind_frequency_days` INT NULL ,\n PRIMARY KEY (`userID`, `topicID`) ,\n INDEX `fk_User_has_Topics_Topics1_idx` (`topicID` ASC) ,\n INDEX `fk_current_event_idx` (`current_eventID` ASC) ,\n INDEX `fk_last_event_idx` (`last_eventID` ASC) ,\n CONSTRAINT `fk_User_has_Topics_Topics1`\n FOREIGN KEY (`topicID` )\n REFERENCES `datr_Topics` (`topicID` )\n ON DELETE CASCADE\n ON UPDATE CASCADE,\n CONSTRAINT `fk_current_event`\n FOREIGN KEY (`current_eventID` )\n REFERENCES `datr_Events` (`eventID` )\n ON DELETE CASCADE\n ON UPDATE CASCADE,\n CONSTRAINT `fk_last_event`\n FOREIGN KEY (`last_eventID` )\n REFERENCES `datr_Events` (`eventID` )\n ON DELETE CASCADE\n ON UPDATE CASCADE)\nENGINE = InnoDB;";
$query_Event_Participant_Status = "CREATE TABLE IF NOT EXISTS `datr_Event_Participant_Status` (\n `statusID` INT NOT NULL ,\n `Name` VARCHAR(45) NOT NULL ,\n PRIMARY KEY (`statusID`) )\nENGINE = InnoDB;";
$query_User_has_Events = "CREATE TABLE IF NOT EXISTS `datr_User_has_Events` (\n `userID` INT NOT NULL ,\n `eventID` INT NOT NULL ,\n `sign_in_datetime` DATETIME NOT NULL ,\n `sign_out_datetime` DATETIME NULL ,\n `completion_date` DATETIME NULL ,\n `status` VARCHAR(45) NOT NULL ,\n PRIMARY KEY (`userID`, `eventID`) ,\n INDEX `fk_User_has_Events_Events1_idx` (`eventID` ASC) ,\n CONSTRAINT `fk_User_has_Events_Events1`\n FOREIGN KEY (`eventID` )\n REFERENCES `datr_Events` (`eventID` )\n ON DELETE CASCADE\n ON UPDATE CASCADE)\nENGINE = InnoDB";
$query_User_has_Locations = "CREATE TABLE IF NOT EXISTS `datr_User_has_Locations` (\n `userID` INT NOT NULL ,\n `locationID` INT NOT NULL ,\n PRIMARY KEY (`userID`, `locationID`) ,\n INDEX `fk_User_has_Locations_Locations1_idx` (`locationID` ASC) ,\n CONSTRAINT `fk_User_has_Locations_Locations1`\n FOREIGN KEY (`locationID` )\n REFERENCES `datr_Locations` (`locationID` )\n ON DELETE CASCADE\n ON UPDATE CASCADE)\nENGINE = InnoDB;";
$query_Mandants = "CREATE TABLE IF NOT EXISTS `datr_Mandants` (\n `mandantID` INT NOT NULL AUTO_INCREMENT ,\n `company` VARCHAR(45) NULL ,\n PRIMARY KEY (`mandantID`) )\nENGINE = InnoDB";
$query_Mandant_has_Locations = "CREATE TABLE IF NOT EXISTS `datr_Mandant_has_Locations` (\n `mandantID` INT NOT NULL ,\n `locationID` INT NOT NULL ,\n PRIMARY KEY (`mandantID`, `locationID`) ,\n INDEX `fk_datr_Mandant_has_datr_Locations_datr_Locations1_idx` (`locationID` ASC) ,\n INDEX `fk_datr_Mandant_has_datr_Locations_datr_Mandants1_idx` (`mandantID` ASC) ,\n CONSTRAINT `fk_datr_Mandant_has_datr_Locations_datr_Mandants1`\n FOREIGN KEY (`mandantID` )\n REFERENCES `datr_Mandants` (`mandantID` )\n ON DELETE NO ACTION\n ON UPDATE NO ACTION,\n CONSTRAINT `fk_datr_Mandant_has_datr_Locations_datr_Locations1`\n FOREIGN KEY (`locationID` )\n REFERENCES `datr_Locations` (`locationID` )\n ON DELETE NO ACTION\n ON UPDATE NO ACTION)\nENGINE = InnoDB";
$query_Courses_have_Topic = "CREATE TABLE IF NOT EXISTS `datr_Course_has_Topic (\n `courseID` int(11) NOT NULL,\n `topicID` int(11) NOT NULL,\n PRIMARY KEY (`courseID`,`topicID`),\n KEY `courseID` (`courseID`),\n KEY `topicID` (`topicID`)\n) ENGINE=InnoDB";
require_wp_db();
global $wpdb;
$queries = array($query_users, $query_topics, $query_locations, $query_addresses, $query_User_has_Locations, $query_Mandants, $query_Mandant_has_Locations, $query_Courses_have_Topic, $query_events, $query_User_has_Topics, $query_Event_Participant_Status, $query_User_has_Events);
foreach ($queries as $value) {
$wpdb->query($value);
}
echo "done";
}
示例2: wp_die
// Validate $prefix: it can only contain letters, numbers and underscores.
if (preg_match('|[^a-z0-9_]|i', $prefix)) {
wp_die(__('<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link));
}
// Test the db connection.
/**#@+
* @ignore
*/
define('DB_NAME', $dbname);
define('DB_USER', $uname);
define('DB_PASSWORD', $pwd);
define('DB_HOST', $dbhost);
/**#@-*/
// Re-construct $wpdb with these new values.
unset($wpdb);
require_wp_db();
/*
* The wpdb constructor bails when WP_SETUP_CONFIG is set, so we must
* fire this manually. We'll fail here if the values are no good.
*/
$wpdb->db_connect();
if (!empty($wpdb->error)) {
wp_die($wpdb->error->get_error_message() . $tryagain_link);
}
// Fetch or generate keys and salts.
$no_api = isset($_POST['noapi']);
if (!$no_api) {
$secret_keys = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/');
}
if ($no_api || is_wp_error($secret_keys)) {
$secret_keys = array();
示例3: setup_bootstrap_hooks
/**
* Set up hooks meant to run during the WordPress bootstrap process
*/
private function setup_bootstrap_hooks()
{
if ($this->config['skip-plugins']) {
$this->setup_skip_plugins_filters();
}
if ($this->config['skip-themes']) {
$this->add_wp_hook('setup_theme', array($this, 'action_setup_theme_wp_cli_skip_themes'), 999);
}
$this->add_wp_hook('wp_die_handler', function () {
return '\\WP_CLI\\Utils\\wp_die_handler';
});
// Prevent code from performing a redirect
$this->add_wp_hook('wp_redirect', 'WP_CLI\\Utils\\wp_redirect_handler');
$this->add_wp_hook('nocache_headers', function ($headers) {
Utils\wp_not_installed();
return $headers;
});
// Get rid of warnings when converting single site to multisite
if (defined('WP_INSTALLING') && $this->is_multisite()) {
$values = array('ms_files_rewriting' => null, 'active_sitewide_plugins' => array(), '_site_transient_update_core' => null, '_site_transient_update_themes' => null, '_site_transient_update_plugins' => null, 'WPLANG' => '');
foreach ($values as $key => $value) {
$this->add_wp_hook("pre_site_option_{$key}", function () use($values, $key) {
return $values[$key];
});
}
}
// Always permit operations against sites, regardless of status
$this->add_wp_hook('ms_site_check', '__return_true');
// Always permit operations against WordPress, regardless of maintenance mode
$this->add_wp_hook('enable_maintenance_mode', function () {
return false;
});
// Use our own debug mode handling instead of WP core
$this->add_wp_hook('enable_wp_debug_mode_checks', function ($ret) {
Utils\wp_debug_mode();
// Check to see of wpdb is errored, instead of waiting for dead_db()
require_wp_db();
global $wpdb;
if (!empty($wpdb->error)) {
Utils\wp_die_handler($wpdb->error);
}
return false;
});
// Never load advanced-cache.php drop-in when WP-CLI is operating
$this->add_wp_hook('enable_loading_advanced_cache_dropin', function () {
return false;
});
// In a multisite install, die if unable to find site given in --url parameter
if ($this->is_multisite()) {
$this->add_wp_hook('ms_site_not_found', function ($current_site, $domain, $path) {
WP_CLI::error("Site {$domain}{$path} not found.");
}, 10, 3);
}
// The APC cache is not available on the command-line, so bail, to prevent cache poisoning
$this->add_wp_hook('muplugins_loaded', function () {
if ($GLOBALS['_wp_using_ext_object_cache'] && class_exists('APC_Object_Cache')) {
WP_CLI::warning('Running WP-CLI while the APC object cache is activated can result in cache corruption.');
WP_CLI::confirm('Given the consequences, do you wish to continue?');
}
}, 0);
// Handle --user parameter
if (!defined('WP_INSTALLING')) {
$config = $this->config;
$this->add_wp_hook('init', function () use($config) {
if (isset($config['user'])) {
$fetcher = new \WP_CLI\Fetchers\User();
$user = $fetcher->get_check($config['user']);
wp_set_current_user($user->ID);
} else {
add_action('init', 'kses_remove_filters', 11);
}
}, 0);
}
}