本文整理汇总了PHP中dbDelta函数的典型用法代码示例。如果您正苦于以下问题:PHP dbDelta函数的具体用法?PHP dbDelta怎么用?PHP dbDelta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbDelta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: anspress_activate
/**
* Create base pages, add roles, add caps and create tables
* @param $network_wide
*/
function anspress_activate($network_wide)
{
// add roles
$ap_roles = new AP_Roles();
$ap_roles->add_roles();
$ap_roles->add_capabilities();
ap_create_base_page();
if (ap_opt('ap_version') != AP_VERSION) {
ap_opt('ap_installed', 'false');
ap_opt('ap_version', AP_VERSION);
}
global $wpdb;
/**
* Run DB quries only if AP_DB_VERSION does not match
*/
if (ap_opt('ap_db_version') != AP_DB_VERSION) {
$charset_collate = !empty($wpdb->charset) ? "DEFAULT CHARACTER SET " . $wpdb->charset : '';
$meta_table = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "ap_meta` (\n\t\t\t\t `apmeta_id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t\t `apmeta_userid` bigint(20) DEFAULT NULL,\n\t\t\t\t `apmeta_type` varchar(256) DEFAULT NULL,\n\t\t\t\t `apmeta_actionid` bigint(20) DEFAULT NULL,\n\t\t\t\t `apmeta_value` text,\n\t\t\t\t `apmeta_param` LONGTEXT DEFAULT NULL,\n\t\t\t\t `apmeta_date` timestamp NULL DEFAULT NULL,\n\t\t\t\t PRIMARY KEY (`apmeta_id`)\n\t\t\t\t)" . $charset_collate . ";";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($meta_table);
ap_opt('ap_db_version', AP_DB_VERSION);
}
if (!get_option('anspress_opt')) {
update_option('anspress_opt', ap_default_options());
} else {
update_option('anspress_opt', get_option('anspress_opt') + ap_default_options());
}
ap_opt('ap_flush', 'true');
flush_rewrite_rules(false);
}
示例2: activate
public static function activate()
{
global $wpdb;
global $charset_collate;
$table_name = $wpdb->prefix . 'gps_locations';
$sql = "DROP TABLE IF EXISTS {$table_name}; \n CREATE TABLE {$table_name} (\n gps_location_id int(10) unsigned NOT NULL AUTO_INCREMENT,\n last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n latitude decimal(10,6) NOT NULL DEFAULT '0.000000',\n longitude decimal(10,6) NOT NULL DEFAULT '0.000000',\n user_name varchar(50) NOT NULL DEFAULT '',\n session_id varchar(50) NOT NULL DEFAULT '',\n speed int(10) unsigned NOT NULL DEFAULT '0',\n direction int(10) unsigned NOT NULL DEFAULT '0',\n distance decimal(10,1) NOT NULL DEFAULT '0.0',\n gps_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n location_method varchar(50) NOT NULL DEFAULT '',\n accuracy int(10) unsigned NOT NULL DEFAULT '0',\n extra_info varchar(255) NOT NULL DEFAULT '',\n event_type varchar(50) NOT NULL DEFAULT '',\n UNIQUE KEY (gps_location_id),\n KEY session_id_index (session_id),\n KEY user_name_index (user_name)\n ) {$charset_collate};";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
$location_row_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name};");
if ($location_row_count == 0) {
$sql = "INSERT INTO {$table_name} VALUES (1,'2007-01-03 11:37:00',47.61,-122.33,'wordpressUser','8BA21D90-3F90-407F-BAAE-800B04B1F5EC',0,0,0.0,'2007-01-03 13:37:00','na',137,'na','wordpress');";
$wpdb->query($sql);
}
$procedure_name = $wpdb->prefix . "get_routes";
$wpdb->query("DROP PROCEDURE IF EXISTS {$procedure_name};");
$sql = "CREATE PROCEDURE {$procedure_name}()\n BEGIN\n CREATE TEMPORARY TABLE temp_routes (\n session_id VARCHAR(50),\n user_name VARCHAR(50),\n start_time DATETIME,\n end_time DATETIME)\n ENGINE = MEMORY;\n\n INSERT INTO temp_routes (session_id, user_name)\n SELECT DISTINCT session_id, user_name\n FROM {$table_name};\n\n UPDATE temp_routes tr\n SET start_time = (SELECT MIN(gps_time) FROM {$table_name} gl\n WHERE gl.session_id = tr.session_id\n AND gl.user_name = tr.user_name);\n\n UPDATE temp_routes tr\n SET end_time = (SELECT MAX(gps_time) FROM {$table_name} gl\n WHERE gl.session_id = tr.session_id\n AND gl.user_name = tr.user_name);\n\n SELECT\n CONCAT('{ \"session_id\": \"', CAST(session_id AS CHAR), '\", \"user_name\": \"', user_name, '\", \"times\": \"(', DATE_FORMAT(start_time, '%b %e %Y %h:%i%p'), ' - ', DATE_FORMAT(end_time, '%b %e %Y %h:%i%p'), ')\" }') json\n FROM temp_routes\n ORDER BY start_time DESC;\n\n DROP TABLE temp_routes;\n END;";
$wpdb->query($sql);
// $wpdb->print_error();
$procedure_name = $wpdb->prefix . "get_route_for_map";
$wpdb->query("DROP PROCEDURE IF EXISTS {$procedure_name};");
$sql = "CREATE PROCEDURE {$procedure_name}(\n _session_id VARCHAR(50))\n BEGIN\n SELECT\n CONCAT('{ \"latitude\": \"', CAST(latitude AS CHAR),'\", \"longitude\": \"', CAST(longitude AS CHAR), '\", \"speed\": \"', CAST(speed AS CHAR), '\", \"direction\": \"', CAST(direction AS CHAR), '\", \"distance\": \"', CAST(distance AS CHAR), '\", \"location_method\": \"', location_method, '\", \"gps_time\": \"', DATE_FORMAT(gps_time, '%b %e %Y %h:%i%p'), '\", \"user_name\": \"', user_name, '\", \"session_id\": \"', CAST(session_id AS CHAR), '\", \"accuracy\": \"', CAST(accuracy AS CHAR), '\", \"extra_info\": \"', extra_info, '\" }') json\n FROM {$table_name}\n WHERE session_id = _session_id\n ORDER BY last_update;\n END;";
$wpdb->query($sql);
$procedure_name = $wpdb->prefix . "delete_route";
$wpdb->query("DROP PROCEDURE IF EXISTS {$procedure_name};");
$sql = "CREATE PROCEDURE {$procedure_name}(\n _session_id VARCHAR(50))\n BEGIN\n DELETE FROM {$table_name}\n WHERE sessionID = _sessionID;\n END;";
$wpdb->query($sql);
}
示例3: tm_password_install
/**
* Activation/Installation
*/
function tm_password_install()
{
global $wpdb;
$sql = "CREATE TABLE " . tm_password_TABLE_NAME . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tusername varchar(255),\n\t\tpassword varchar(255),\n\t\tUNIQUE KEY id (id)\n\t);";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
}
示例4: initialize
/**
* Initialize the table if it doesn't exist.
*/
function initialize($force = false)
{
global $wpdb;
if ($wpdb->get_var("SHOW TABLES LIKE '{$this->table_name}'") != $this->table_name || $force) {
$sql = "CREATE TABLE {$this->table_name} (\n";
$statements = array();
foreach ($this->schema_info as $info) {
list($name, $type, $size, $extra) = $info;
$statement = "{$name} {$type}";
if (!empty($size)) {
$statement .= "({$size})";
}
if (!empty($extra)) {
$statement .= " {$extra}";
}
$statements[] = $statement;
}
$sql .= implode(",\n", $statements) . ");";
if (!$wpdb->is_mock) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
return true;
}
}
return false;
}
示例5: speedymarket_tables
function speedymarket_tables()
{
//Get the table name with the WP database prefix
global $wpdb;
$speedymarket_table_version = "1.0";
$installed_ver = get_option("speedymarket_table_version");
//Check if the table already exists and if the table is up to date, if not create it
if ($wpdb->get_var("SHOW TABLES LIKE '{$wpc_cat_table}'") != $wpc_cat_table || $installed_ver != $speedymarket_table_version) {
$sql = "CREATE TABLE `tb_article` (\r\n `id_article` int(11) NOT NULL,\r\n `a_designation` varchar(100) NOT NULL,\r\n `a_pht` float(6,2) DEFAULT NULL,\r\n `a_description` text,\r\n `a_quantite_stock` int(11) DEFAULT NULL,\r\n `a_visible` tinyint(1) NOT NULL,\r\n `id_categorie` int(11) DEFAULT NULL,\r\n `url_image` varchar(200) DEFAULT NULL,\r\n `id_tva` int(11) DEFAULT NULL\r\n UNIQUE KEY id_article (id)\r\n )";
$sql1 = "CREATE TABLE `tb_categorie` (\r\n`id_categorie` int(11) NOT NULL,\r\n `c_libelle` varchar(100) NOT NULL,\r\n `id_categorie_mere` int(11) DEFAULT NULL,\r\n `url_image` varchar(200) DEFAULT NULL\r\n )";
$sql2 = "CREATE TABLE `tb_client` (\r\n `id_personne` int(11) NOT NULL,\r\n UNIQUE KEY id_personne()\r\n)";
$sql3 = "CREATE TABLE `tb_commande` (\r\n`id_commande` int(11) NOT NULL,\r\n `c_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n `c_dateretrait` date DEFAULT NULL,\r\n `id_statut` int(11) DEFAULT NULL,\r\n `client_id_pers` int(11) DEFAULT NULL,\r\n `prepa_id_pers` int(11) DEFAULT NULL\r\n)";
$sql4 = "CREATE TABLE `tb_image` (\r\n `url_image` varchar(200) NOT NULL,\r\n `i_nom` varchar(100) NOT NULL,\r\n `i_libelle` varchar(100) DEFAULT NULL\r\n)";
$sql5 = "CREATE TABLE IF NOT EXISTS `tb_ligne_commande` (\r\n `id_article` int(11) NOT NULL,\r\n `id_commande` int(11) NOT NULL,\r\n `qte_cmde` int(11) NOT NULL\r\n)";
$sql6 = "CREATE TABLE IF NOT EXISTS `tb_personne` (\r\n`id_personne` int(11) NOT NULL,\r\n `p_nom` varchar(100) NOT NULL,\r\n `p_prenom` varchar(100) NOT NULL,\r\n `p_arue` varchar(100) DEFAULT NULL,\r\n `p_aville` varchar(100) NOT NULL,\r\n `p_acp` int(11) NOT NULL,\r\n `p_tel` int(11) DEFAULT NULL,\r\n `p_mail` varchar(100) NOT NULL,\r\n `p_mdp` varchar(128) NOT NULL\r\n)";
$sql7 = "CREATE TABLE IF NOT EXISTS `tb_preparateur` (\r\n `id_personne` int(11) NOT NULL\r\n)";
$sql8 = "CREATE TABLE IF NOT EXISTS `tb_statut` (\r\n`id_statut` int(11) NOT NULL,\r\n `s_libelle` varchar(50) NOT NULL\r\n)";
$sql9 = "CREATE TABLE IF NOT EXISTS `tb_tva` (\r\n`id_tva` int(11) NOT NULL,\r\n `t_libelle` varchar(100) NOT NULL,\r\n `t_taux` float(4,3) NOT NULL\r\n)";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
update_option("speedymarket_table_version", $speedymarket_table_version);
}
//Add database table versions to options
add_option("wpc_cat_table_version", $speedymarket_table_version);
}
示例6: delta
protected function delta($query)
{
if (!function_exists('dbDelta')) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
return dbDelta($query);
}
示例7: set_up_options
function set_up_options()
{
global $wpdb;
$table_name = $wpdb->prefix . 'chatwee_moderators';
$sql = "CREATE TABLE {$table_name} (\r\n\t\t id int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t user_id int(11) DEFAULT NULL,\r\n\t\t UNIQUE KEY id (id)\r\n\t\t);";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
register_setting('chatwee-settings-group', 'is_home');
register_setting('chatwee-settings-group', 'is_search');
register_setting('chatwee-settings-group', 'is_archive');
register_setting('chatwee-settings-group', 'is_page');
register_setting('chatwee-settings-group', 'is_single');
register_setting('chatwee-settings-group', 'ssostatus');
register_setting('chatwee-settings-group', 'clientid');
register_setting('chatwee-settings-group', 'keyapi');
register_setting('chatwee-settings-group', 'loginallsubdomains');
register_setting('chatwee-settings-group', 'group_moderators_editor');
register_setting('chatwee-settings-group', 'group_moderators_author');
register_setting('chatwee-settings-group', 'group_moderators_contributor');
register_setting('chatwee-settings-group', 'group_moderators_subscriber');
register_setting('chatwee-settings-group', 'display_format');
update_option('chatwee-settings-group[is_home]', "on");
update_option('chatwee-settings-group[display_format]', 0);
update_option('chatwee-settings-group[is_search]', "on");
update_option('chatwee-settings-group[is_archive]', "on");
update_option('chatwee-settings-group[is_single]', "on");
update_option('chatwee-settings-group[is_page]', "on");
update_option('chatwee-settings-group[ssostatus]', "on");
update_option('chatwee-settings-group[loginallsubdomains]', "on");
update_option('chatwee', "");
}
示例8: install
/**
* Here we install the tables and initial data needed to
* power our special functions
*/
function install()
{
global $wpdb, $db_version;
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
$table = $wpdb->prefix . 'wik_sources';
$link = $wpdb->prefix . 'wik_source_types';
$life = $wpdb->prefix . 'wik_life_data';
$q = '';
if ($wpdb->get_var("show tables like '{$table}'") != $table) {
$q = "CREATE TABLE " . $table . "( \r\n\t\t\t\tid int NOT NULL AUTO_INCREMENT,\r\n\t\t\t\ttitle varchar(255) NOT NULL,\r\n\t\t\t\tprofile_url varchar(255) NOT NULL,\r\n\t\t\t\tfeed_url varchar(255) NOT NULL,\r\n\t\t\t\ttype boolean NOT NULL,\r\n\t\t\t\tlifestream boolean NOT NULL,\r\n\t\t\t\tupdates boolean NOT NULL,\r\n\t\t\t\tfavicon varchar(255) NOT NULL,\r\n\t\t\t\tUNIQUE KEY id (id)\r\n\t\t\t);";
}
if ($wpdb->get_var("show tables like '{$life}'") != $life) {
$q .= "CREATE TABLE " . $life . "(\r\n\t\t\t\tid int NOT NULL AUTO_INCREMENT,\r\n\t\t\t\tname varchar(255) NOT NULL,\r\n\t\t\t\tcontent TEXT NOT NULL,\r\n\t\t\t\tdate varchar(255) NOT NULL,\r\n\t\t\t\tlink varchar(255) NOT NULL,\r\n\t\t\t\tenabled boolean NOT NULL,\r\n\t\t\t\tUNIQUE KEY id (id)\r\n\t\t\t);";
}
if ($wpdb->get_var("show tables like '{$link}'") != $link) {
$q .= "CREATE TABLE " . $link . "( \r\n\t\t\t\tid int NOT NULL AUTO_INCREMENT,\r\n\t\t\t\ttype_id tinyint(4) NOT NULL,\r\n\t\t\t\tname varchar(255) NOT NULL,\r\n\t\t\t\tUNIQUE KEY id (id)\r\n\t\t\t);";
}
if ($q != '') {
dbDelta($q);
}
$types = array(array('type_id' => '3', 'name' => 'Social Network'), array('type_id' => '2', 'name' => 'Website/Blog'), array('type_id' => '1', 'name' => 'Images'));
foreach ($types as $type) {
if (!$wpdb->get_var("SELECT type_id FROM {$link} WHERE type_id = " . $type['type_id'])) {
$i = "INSERT INTO " . $link . " (id,type_id,name) VALUES('', '" . $type['type_id'] . "','" . $type['name'] . "')";
$query = $wpdb->query($i);
}
}
wp_add_option('wik_db_version', $db_version);
}
示例9: nanodesigns_email_downloads_activate
/**
* Set basic settings on the activation of the plugin.
* - Saved in 'options' table.
* - Creating custom table for storing email addresses.
* ------------------------------------------------------------------------------
*/
function nanodesigns_email_downloads_activate()
{
/**
* Creating a custom table.
* @since 1.0.1
* -----------
*/
global $wpdb, $nano_db_version;
$table = $wpdb->prefix . 'download_email';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table}'") != $table) {
$sql = "CREATE TABLE {$table} (\n id mediumint(9) NOT NULL AUTO_INCREMENT,\n email tinytext NOT NULL,\n UNIQUE KEY id (id)\n );";
//reference to upgrade.php file
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
}
//endif($wpdb->get_var
update_option("nano_ed_db_version", $nano_db_version);
/**
* Add the necessary default settings to the 'options table'.
* @since 1.0.0
* -----------
*/
$noreply_email = noreply_email();
$admin_email = get_option('admin_email');
$admin_user = get_user_by('email', $admin_email);
$ed_settings = array('ed_sender_email' => $noreply_email, 'ed_sender_name' => $admin_user->display_name);
update_option('email_downloads_settings', $ed_settings);
}
示例10: createDatabaseTable
function createDatabaseTable()
{
global $wpdb;
$options = array();
$options['title'] = 'Quote Rotator';
$options['delay'] = 5;
$options['fade'] = 2;
$options['fontsize'] = 12;
$options['fontunit'] = 'px';
if (!get_option('widgetQuoteRotator')) {
add_option('widgetQuoteRotator', $options);
}
if ($wpdb->get_var("SHOW TABLES LIKE `" . $this->tableName . "`") != $this->tableName) {
$sql = "CREATE TABLE `" . $wpdb->prefix . "QuoteRotator` (`id` MEDIUMINT(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, `quote` TEXT NULL);";
//$sql = "CREATE TABLE `" . $this->tableName . "` (`id` MEDIUMINT(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, `quote` TEXT NULL);";
require_once ABSPATH . 'wp-admin/upgrade-functions.php';
dbDelta($sql);
$options['version'] = $this->currentVersion;
}
$sql = "ALTER TABLE `" . $this->tableName . "` ADD `author` VARCHAR(255) NOT NULL AFTER `quote`;";
$wpdb->query($sql);
$sql = "RENAME TABLE `wp_QuoteRotator` TO `{$this->tableName}`;";
$wpdb->query($sql);
$sql = "ALTER TABLE `" . $this->tableName . "` CHANGE `quote` `quote` TEXT NULL;";
$wpdb->query($sql);
update_option('widgetQuoteRotator', $options);
delete_option('widgetizeQuoteRotator');
}
示例11: alm_create_table
function alm_create_table()
{
global $wpdb;
$table_name = $wpdb->prefix . "alm";
$blog_id = $wpdb->blogid;
$defaultRepeater = '<li <?php if (!has_post_thumbnail()) { ?> class="no-img"<?php } ?>><?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(100,100));}?><h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><p class="entry-meta"><?php the_time("F d, Y"); ?></p><?php the_excerpt(); ?></li>';
/* MULTISITE */
/* if this is a multisite blog and it's not id = 1, create default template */
if ($blog_id > 1) {
$dir = ALM_PATH . 'core/repeater/' . $blog_id;
if (!is_dir($dir)) {
mkdir($dir);
}
$file = ALM_PATH . 'core/repeater/' . $blog_id . '/default.php';
if (!file_exists($file)) {
$tmp = fopen($file, 'w');
$w = fwrite($tmp, $defaultRepeater);
fclose($tmp);
}
}
//Create table, if it doesn't already exist.
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
$sql = "CREATE TABLE {$table_name} (\n\t\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\tname text NOT NULL,\n\t\t\trepeaterDefault longtext NOT NULL,\n\t\t\trepeaterType text NOT NULL,\n\t\t\tpluginVersion text NOT NULL,\n\t\t\tUNIQUE KEY id (id)\n\t\t);";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
//Insert the default data in created table
$wpdb->insert($table_name, array('name' => 'default', 'repeaterDefault' => $defaultRepeater, 'repeaterType' => 'default', 'pluginVersion' => ALM_VERSION));
}
}
示例12: activate
public static function activate()
{
global $wpdb, $choobs_wp_mailchimp_db_version, $choobs_wp_mailchimp_forms_table;
if (!isset($choobs_wp_mailchimp_forms_table)) {
return false;
}
$installed_version = get_option("choobs_wp_mailchimp_db_version");
if ($installed_version == $choobs_wp_mailchimp_db_version) {
return true;
}
$table_name = $wpdb->prefix . $choobs_wp_mailchimp_forms_table;
$charset_collate = $wpdb->get_charset_collate();
/**
* idform, int, primary key
* form_list, text, mailchimp list id
* form_label, text, title of the form
* form_html, text, html body of the form
* form_shortcode, text, shortcode generated for the form
* edit_date, datetime, time of editing the form
* edited_by, int, user id of editing user
* form_status, enum, [active, inacrive, draft]
*/
$sql = "CREATE TABLE {$table_name} (\n\t\t\t\t\tidform bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tform_list text NOT NULL,\n\t\t\t\t\tform_label text NOT NULL,\n\t\t\t\t\tform_html text NOT NULL,\n\t\t\t\t\tform_shortcode text NOT NULL,\n\t\t\t\t\tedit_date datetime,\n\t\t\t\t\tedited_by bigint(20) UNSIGNED,\n\t\t\t\t\tform_status enum('active', 'inactive', 'draft') DEFAULT 'draft' NOT NULL,\n\t\t\t\t\tPRIMARY KEY (idform)\n\t\t\t\t\t) {$charset_collate};";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
update_option('choobs_wp_mailchimp_db_version', $choobs_wp_mailchimp_db_version);
}
示例13: es_af_activation
public static function es_af_activation()
{
global $wpdb;
$es_af_pluginversion = "";
$es_af_tableexists = "YES";
$es_af_pluginversion = get_option("es_af_pluginversion");
$es_af_dbtable = $wpdb->get_var("show tables like '" . $wpdb->prefix . ES_AF_TABLE . "'");
if ($es_af_dbtable != "") {
if (strtoupper($es_af_dbtable) != strtoupper($wpdb->prefix . ES_AF_TABLE)) {
$es_af_tableexists = "NO";
}
} else {
$es_af_tableexists = "NO";
}
if ($es_af_tableexists == "NO" || $es_af_pluginversion != ES_AF_DBVERSION) {
$sSql = "CREATE TABLE " . $wpdb->prefix . ES_AF_TABLE . " (\n\t\t\t\t es_af_id mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t es_af_title VARCHAR(1024) DEFAULT 'Advanced Form 1' NOT NULL,\n\t\t\t\t es_af_desc VARCHAR(1024) DEFAULT 'Welcome to Email Subscribers Advanced Form' NOT NULL,\n\t\t\t\t es_af_name VARCHAR(20) DEFAULT 'YES' NOT NULL,\n\t\t\t\t es_af_name_mand VARCHAR(20) DEFAULT 'YES' NOT NULL,\t \n\t\t\t\t es_af_email VARCHAR(20) DEFAULT 'YES' NOT NULL,\n\t\t\t\t es_af_email_mand VARCHAR(20) DEFAULT 'YES' NOT NULL,\n\t\t\t\t es_af_group VARCHAR(20) DEFAULT 'YES' NOT NULL,\n\t\t\t\t es_af_group_mand VARCHAR(20) DEFAULT 'YES' NOT NULL,\n\t\t\t\t es_af_group_list VARCHAR(1024) DEFAULT 'Public' NOT NULL,\n\t\t\t\t es_af_plugin VARCHAR(20) DEFAULT 'es-af' NOT NULL,\n\t\t\t\t UNIQUE KEY es_af_id (es_af_id)\n\t\t\t ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sSql);
if ($es_af_pluginversion == "") {
add_option('es_af_pluginversion', "1.0");
} else {
update_option("es_af_pluginversion", ES_AF_DBVERSION);
}
if ($es_af_tableexists == "NO") {
$welcome_text = "Advanced Form 1";
$rows_affected = $wpdb->insert($wpdb->prefix . ES_AF_TABLE, array('es_af_title' => $welcome_text));
}
}
}
示例14: ERP_DB
public function ERP_DB()
{
global $wpdb;
//create the name of the table including the wordpress prefix (wp_ etc)
$EPR_user = $wpdb->prefix . "EPR_user";
$EPR_user_meta = $wpdb->prefix . "EPR_user_meta";
//$wpdb->show_errors();
//check if there are any tables of that name already
if ($wpdb->get_var("show tables like '{$EPR_user}'") !== $EPR_user) {
//create your sql
$sql = "CREATE TABLE " . $EPR_user . " (\n ID bigint(20) NOT NULL AUTO_INCREMENT,\n fname VARCHAR (10) NOT NULL,\n lname VARCHAR(10) NOT NULL,\n email VARCHAR(20) NOT NULL,\n staddress VARCHAR(20) NOT NULL,\n city VARCHAR(20) NOT NULL,\n state VARCHAR(20) NOT NULL,\n Zip VARCHAR(20) NOT NULL,\n phone VARCHAR(20) NOT NULL,\n eve_phone VARCHAR(20) NOT NULL,\n date_of_birth VARCHAR(20) NOT NULL,\n medication VARCHAR(20) NOT NULL,\n term_option VARCHAR(20) NOT NULL,\n term_coverag_amount VARCHAR(20) NOT NULL,\n Exterior_Wall_Type VARCHAR(20) NOT NULL,\n property_type VARCHAR(20) NOT NULL,\n year_build VARCHAR(20) NOT NULL,\n squar_footge VARCHAR(20) NOT NULL,\n property_country VARCHAR(20) NOT NULL,\n swimming_pool VARCHAR(20) NOT NULL,\n driver_first_name1 VARCHAR(20) NOT NULL,\n driver_last_name1 VARCHAR(20) NOT NULL,\n driver_birthdate1 VARCHAR(20) NOT NULL,\n driver_maritual_statues1 VARCHAR(20) NOT NULL,\n driver_1st_violation_description1 VARCHAR(20) NOT NULL,\n driver_first_name2 VARCHAR(20) NOT NULL,\n driver_last_name2 VARCHAR(20) NOT NULL,\n driver_birthdate2 VARCHAR(20) NOT NULL,\n driver_maritual_statues2 VARCHAR(20) NOT NULL,\n driver_1nd_violation_description2 VARCHAR(20) NOT NULL,\n driver_first_name3 VARCHAR(20) NOT NULL,\n driver_last_name3 VARCHAR(20) NOT NULL,\n driver_birthdate3 VARCHAR(20) NOT NULL,\n driver_maritual_statues3 VARCHAR(20) NOT NULL,\n driver_1nd_violation_description3 VARCHAR(20) NOT NULL,\n Vehicle_year1 VARCHAR(20) NOT NULL,\n Vehicle_Make1 VARCHAR(20) NOT NULL,\n Vehicle_Model1 VARCHAR(20) NOT NULL,\n Vehicle_Deductible1 VARCHAR(20) NOT NULL,\n Vehicle_year2 VARCHAR(20) NOT NULL,\n Vehicle_Make2 VARCHAR(20) NOT NULL,\n Vehicle_Model2 VARCHAR(20) NOT NULL,\n Vehicle_Deductible2 VARCHAR(20) NOT NULL,\n Vehicle_year3 VARCHAR(20) NOT NULL,\n Vehicle_Make3 VARCHAR(20) NOT NULL,\n Vehicle_Model3 VARCHAR(20) NOT NULL,\n Vehicle_Deductible3 VARCHAR(20) NOT NULL,\n What_are_your_current_liability_limits VARCHAR(20) NOT NULL,\n Current_Resident_Status VARCHAR(20) NOT NULL,\n Requested_Policy_Start_Date VARCHAR(20) NOT NULL,\n Design_Type VARCHAR(20) NOT NULL,\n Square_Footage VARCHAR(20) NOT NULL,\n Number_of_Stories VARCHAR(20) NOT NULL,\n Foundation_Type VARCHAR(20) NOT NULL,\n Roof_Type VARCHAR(20) NOT NULL,\n Property_Extras VARCHAR(20) NOT NULL,\n Heating_Type VARCHAR(20) NOT NULL,\n Garage_Type VARCHAR(20) NOT NULL,\n Bathrooms VARCHAR(20) NOT NULL,\n Additional_Comments VARCHAR(20) NOT NULL,\n square_ft VARCHAR(10) NOT NULL,\n Promotion_Code VARCHAR(10) NOT NULL,\n dogs VARCHAR(10) NOT NULL,\n hear_about_us VARCHAR(50) NOT NULL,\n method_to_contuct VARCHAR(50) NOT NULL,\n type VARCHAR(50) NOT NULL,\n UNIQUE KEY ID (ID));";
}
if ($wpdb->get_var("show tables like '{$EPR_user_meta}'") !== $EPR_user_meta) {
//create your sql
$EPR_user_meta_sql = "CREATE TABLE " . $EPR_user_meta . " (\n ID bigint(20) NOT NULL AUTO_INCREMENT,\n fname VARCHAR (10) NOT NULL,\n lname VARCHAR(10) NOT NULL,\n email VARCHAR(20) NOT NULL,\n staddress VARCHAR(20) NOT NULL,\n city VARCHAR(20) NOT NULL,\n state VARCHAR(20) NOT NULL,\n Zip VARCHAR(20) NOT NULL,\n phone VARCHAR(20) NOT NULL,\n eve_phone VARCHAR(20) NOT NULL,\n date_of_birth VARCHAR(20) NOT NULL,\n medication VARCHAR(20) NOT NULL,\n term_option VARCHAR(20) NOT NULL,\n term_coverag_amount VARCHAR(20) NOT NULL,\n Exterior_Wall_Type VARCHAR(20) NOT NULL,\n property_type VARCHAR(20) NOT NULL,\n year_build VARCHAR(20) NOT NULL,\n squar_footge VARCHAR(20) NOT NULL,\n property_country VARCHAR(20) NOT NULL,\n swimming_pool VARCHAR(20) NOT NULL,\n 1driver_first_name VARCHAR(20) NOT NULL,\n 1driver_last_name VARCHAR(20) NOT NULL,\n 1st_driver_birthdate VARCHAR(20) NOT NULL,\n 1driver_maritual_statues VARCHAR(20) NOT NULL,\n 1st_driver_1st_violation_description VARCHAR(20) NOT NULL,\n 2driver_first_name VARCHAR(20) NOT NULL,\n 2driver_last_name VARCHAR(20) NOT NULL,\n 2nd_driver_birthdate VARCHAR(20) NOT NULL,\n 2driver_maritual_statues VARCHAR(20) NOT NULL,\n 2nd_driver_1nd_violation_description VARCHAR(20) NOT NULL,\n 3driver_first_name VARCHAR(20) NOT NULL,\n 3driver_last_name VARCHAR(20) NOT NULL,\n 3nd_driver_birthdate VARCHAR(20) NOT NULL,\n 3driver_maritual_statues VARCHAR(20) NOT NULL,\n 3rd_driver_1nd_violation_description VARCHAR(20) NOT NULL,\n 1_Vehicle_year VARCHAR(20) NOT NULL,\n 1_Vehicle_Make VARCHAR(20) NOT NULL,\n 1_Vehicle_Model VARCHAR(20) NOT NULL,\n 1_Vehicle_Deductible VARCHAR(20) NOT NULL,\n 2_Vehicle_year VARCHAR(20) NOT NULL,\n 2_Vehicle_Make VARCHAR(20) NOT NULL,\n 2_Vehicle_Model VARCHAR(20) NOT NULL,\n 2_Vehicle_Deductible VARCHAR(20) NOT NULL,\n 3_Vehicle_year VARCHAR(20) NOT NULL,\n 3_Vehicle_Make VARCHAR(20) NOT NULL,\n 3_Vehicle_Model VARCHAR(20) NOT NULL,\n 3_Vehicle_Deductible VARCHAR(20) NOT NULL,\n What_are_your_current_liability_limits VARCHAR(20) NOT NULL,\n Current_Resident_Status VARCHAR(20) NOT NULL,\n Requested_Policy_Start_Date VARCHAR(20) NOT NULL,\n Design_Type VARCHAR(20) NOT NULL,\n Square_Footage VARCHAR(20) NOT NULL,\n Number_of_Stories VARCHAR(20) NOT NULL,\n Foundation_Type VARCHAR(20) NOT NULL,\n Roof_Type VARCHAR(20) NOT NULL,\n Property_Extras VARCHAR(20) NOT NULL,\n Heating_Type VARCHAR(20) NOT NULL,\n Garage_Type VARCHAR(20) NOT NULL,\n Bathrooms VARCHAR(20) NOT NULL,\n Additional_Comments VARCHAR(20) NOT NULL,\n square_ft VARCHAR(10) NOT NULL,\n Promotion_Code VARCHAR(10) NOT NULL,\n dogs VARCHAR(10) NOT NULL,\n hear_about_us VARCHAR(50) NOT NULL,\n method_to_contuct VARCHAR(50) NOT NULL,\n UNIQUE KEY ID (ID));";
}
//include the wordpress db functions
require_once ABSPATH . 'wp-admin/upgrade-functions.php';
dbDelta($sql);
dbDelta($EPR_user_meta_sql);
//register the new table with the wpdb object
if (!isset($wpdb->EPR_user_meta)) {
$wpdb->EPR_user_meta = $EPR_user_meta;
//add the shortcut so you can use $wpdb->EPR_user
$wpdb->tables[] = str_replace($wpdb->prefix, '', $EPR_user_meta);
}
if (!isset($wpdb->EPR_user)) {
$wpdb->EPR_user = $EPR_user;
//add the shortcut so you can use $wpdb->EPR_user
$wpdb->tables[] = str_replace($wpdb->prefix, '', $EPR_user);
}
}
示例15: prtools_install
/**
* PR fetcher installation
*/
function prtools_install()
{
global $wpdb;
global $prtools_url_table;
global $prtools_pr_table;
/**
* Installing tables
*/
if ($wpdb->get_var("SHOW TABLES LIKE '" . $prtools_url_table . "'") != $prtools_url_table) {
$sql = "CREATE TABLE " . $prtools_url_table . " (\n\t\tID int(11) NOT NULL AUTO_INCREMENT,\n\t\tentrydate int(11) DEFAULT '0' NOT NULL,\n\t\tlastupdate int(11) DEFAULT '0' NOT NULL,\n\t\tlastcheck int(11) NOT NULL,\n\t\turl_type char(50) NOT NULL,\n\t\turl VARCHAR(500) NOT NULL,\n\t\ttitle text NOT NULL,\n\t\tpr int(11) NOT NULL,\n\t\tdiff_last_pr int(1) NOT NULL,\n\t\tpr_entries int(11) NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t);";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
}
if ($wpdb->get_var("SHOW TABLES LIKE '" . $prtools_pr_table . "'") != $prtools_pr_table) {
$sql = "CREATE TABLE " . $prtools_pr_table . " (\n\t\tID int(11) NOT NULL AUTO_INCREMENT,\n\t\tentrydate int(11) DEFAULT '0' NOT NULL,\n\t\turl VARCHAR(500) NOT NULL,\n\t\tpr int(11) NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t);";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
}
update_url_table();
add_option("prtools_db_version", '1.0');
/**
* Setting standard options
*/
if (get_option('pagerank_tools_settings') == "") {
$prtools_settings['fetch_interval'] = 5;
$prtools_settings['fetch_url_interval'] = 120;
$prtools_settings['fetch_url_interval_new'] = 14;
$prtools_settings['fetch_num'] = 1;
$prtools_settings['fetch_titles_num'] = 2;
$prtools_settings['running_number'] = 1;
update_option('pagerank_tools_settings', $prtools_settings);
}
}