本文整理汇总了PHP中maybe_add_column函数的典型用法代码示例。如果您正苦于以下问题:PHP maybe_add_column函数的具体用法?PHP maybe_add_column怎么用?PHP maybe_add_column使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了maybe_add_column函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activation
/**
* Create the tables if needed
*
* @param void
* @return void
* @author Nicolas Juen
*/
public static function activation()
{
/* @var $wpdb wpdb */
global $wpdb;
// Charset
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
// Add one library admin function for next function
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
// Campaign Table
maybe_create_table($wpdb->bea_s_campaigns, "CREATE TABLE " . $wpdb->bea_s_campaigns . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`add_date` datetime NOT NULL,\n\t\t\t`scheduled_from` datetime NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`from_name` varchar(255) NOT NULL,\n\t\t\t`from` varchar(255) NOT NULL,\n\t\t\t`subject` text NOT NULL\n\t\t) {$charset_collate};");
add_clean_index($wpdb->bea_s_campaigns, 'id');
add_clean_index($wpdb->bea_s_campaigns, 'current_status');
// Receiver Table
maybe_create_table($wpdb->bea_s_receivers, "CREATE TABLE " . $wpdb->bea_s_receivers . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`email` varchar(255) NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`bounce_cat` varchar(20) NOT NULL,\n\t\t\t`bounce_type` varchar(20) NOT NULL,\n\t\t\t`bounce_no` varchar(10) NOT NULL\n\t\t) {$charset_collate};");
maybe_add_column($wpdb->bea_s_receivers, 'bounce_cat', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_cat char(20)");
maybe_add_column($wpdb->bea_s_receivers, 'bounce_type', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_type char(20)");
maybe_add_column($wpdb->bea_s_receivers, 'bounce_no', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_no char(10)");
add_clean_index($wpdb->bea_s_receivers, 'email');
add_clean_index($wpdb->bea_s_receivers, 'current_status');
// Recesiver/campaign link table
maybe_create_table($wpdb->bea_s_re_ca, "CREATE TABLE " . $wpdb->bea_s_re_ca . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`id_campaign` int NOT NULL,\n\t\t\t`id_receiver` int NOT NULL,\n\t\t\t`id_content` int NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`response` varchar(10) NOT NULL\n\t\t) {$charset_collate};");
add_clean_index($wpdb->bea_s_re_ca, 'current_status');
add_clean_index($wpdb->bea_s_re_ca, 'id_campaign');
add_clean_index($wpdb->bea_s_re_ca, 'id_receiver');
// Content Table
maybe_create_table($wpdb->bea_s_contents, "CREATE TABLE " . $wpdb->bea_s_contents . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`html` longtext NOT NULL,\n\t\t\t`text` longtext NOT NULL\n\t\t) {$charset_collate};");
add_clean_index($wpdb->bea_s_contents, 'id');
// Attachment Table
maybe_create_table($wpdb->bea_s_attachments, "CREATE TABLE " . $wpdb->bea_s_attachments . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`campaign_id` int NOT NULL,\n\t\t\t`path` longtext NOT NULL\n\t\t) {$charset_collate};");
add_clean_index($wpdb->bea_s_attachments, 'id');
add_clean_index($wpdb->bea_s_attachments, 'campaign_id');
}
示例2: ratings_activate
function ratings_activate()
{
global $wpdb;
// Create Post Ratings Table
$create_sql = "CREATE TABLE {$wpdb->ratings} (" . "rating_id INT(11) NOT NULL auto_increment," . "rating_postid INT(11) NOT NULL ," . "rating_posttitle TEXT NOT NULL," . "rating_rating INT(2) NOT NULL ," . "rating_timestamp VARCHAR(15) NOT NULL ," . "rating_ip VARCHAR(40) NOT NULL ," . "rating_host VARCHAR(200) NOT NULL," . "rating_username VARCHAR(50) NOT NULL," . "rating_userid int(10) NOT NULL default '0'," . "PRIMARY KEY (rating_id));";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($create_sql);
// Add In Options (4 Records)
add_option('postratings_image', 'stars');
add_option('postratings_max', '5');
add_option('postratings_template_vote', '%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)<br />%RATINGS_TEXT%');
add_option('postratings_template_text', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%' . __(',', 'wp-postratings') . ' <strong>' . __('rated', 'wp-postratings') . '</strong></em>)');
add_option('postratings_template_none', '%RATINGS_IMAGES_VOTE% (' . __('No Ratings Yet', 'wp-postratings') . ')<br />%RATINGS_TEXT%');
// Database Upgrade For WP-PostRatings 1.02
add_option('postratings_logging_method', '3');
add_option('postratings_allowtorate', '2');
// Database Uprade For WP-PostRatings 1.04
maybe_add_column($wpdb->ratings, 'rating_userid', "ALTER TABLE {$wpdb->ratings} ADD rating_userid INT( 10 ) NOT NULL DEFAULT '0';");
// Database Uprade For WP-PostRatings 1.05
add_option('postratings_ratingstext', array(__('1 Star', 'wp-postratings'), __('2 Stars', 'wp-postratings'), __('3 Stars', 'wp-postratings'), __('4 Stars', 'wp-postratings'), __('5 Stars', 'wp-postratings')));
add_option('postratings_template_highestrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> %RATINGS_IMAGES% (%RATINGS_AVERAGE% ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)</li>');
// Database Upgrade For WP-PostRatings 1.11
add_option('postratings_ajax_style', array('loading' => 1, 'fading' => 1));
// Database Upgrade For WP-PostRatings 1.20
add_option('postratings_ratingsvalue', array(1, 2, 3, 4, 5));
add_option('postratings_customrating', 0);
add_option('postratings_template_permission', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%</em>)<br /><em>' . __('You need to be a registered member to rate this.', 'wp-postratings') . '</em>');
// Database Upgrade For WP-PostRatings 1.30
add_option('postratings_template_mostrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> - %RATINGS_USERS% ' . __('votes', 'wp-postratings') . '</li>');
// Database Upgrade For WP-PostRatings 1.50
delete_option('widget_ratings_highest_rated');
delete_option('widget_ratings_most_rated');
// Set 'manage_ratings' Capabilities To Administrator
$role = get_role('administrator');
$role->add_cap('manage_ratings');
}
示例3: upgrade_100
function upgrade_100()
{
global $wpdb, $tableposts, $tablecomments, $tablecategories, $tableoptionvalues, $tableoptiongroups, $tableoptiongroup_options, $tableoptions, $tablepost2cat, $tablelinks, $tableusers;
maybe_add_column($tableposts, 'post_name', "ALTER TABLE `{$tableposts}` ADD `post_name` VARCHAR(200) NOT NULL");
maybe_add_column($tableposts, 'to_ping', "ALTER TABLE {$tableposts} ADD `to_ping` TEXT NOT NULL");
maybe_add_column($tableposts, 'pinged', "ALTER TABLE {$tableposts} ADD `pinged` TEXT NOT NULL");
maybe_add_column($tableposts, 'post_modified', "ALTER TABLE {$tableposts} ADD `post_modified` DATETIME NOT NULL");
maybe_add_column($tableposts, 'post_content_filtered', "ALTER TABLE {$tableposts} ADD `post_content_filtered` TEXT NOT NULL");
maybe_add_column($tablecategories, 'category_nicename', "ALTER TABLE `{$tablecategories}` ADD `category_nicename` VARCHAR(200) NOT NULL");
maybe_add_column($tablecategories, 'category_description', "ALTER TABLE `{$tablecategories}` ADD `category_description` TEXT NOT NULL");
maybe_add_column($tablecategories, 'category_parent', "ALTER TABLE `{$tablecategories}` ADD `category_parent` INT(4) NOT NULL");
maybe_add_column($tablelinks, 'link_rss', "ALTER TABLE `{$tablelinks}` ADD `link_rss` VARCHAR( 255 ) NOT NULL;");
maybe_add_column($tableusers, 'user_description', "ALTER TABLE `{$tableusers}` ADD `user_description` TEXT NOT NULL");
maybe_add_column($tablecomments, 'comment_approved', "ALTER TABLE {$tablecomments} ADD COLUMN comment_approved ENUM('0', '1') DEFAULT '1' NOT NULL");
// Create indicies
add_clean_index($tableposts, 'post_name');
add_clean_index($tablecategories, 'category_nicename');
add_clean_index($tablecomments, 'comment_approved');
// Options stuff
if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'comment_moderation'")) {
$wpdb->query("INSERT INTO {$tableoptions}\n\t\t\t(option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)\n\t\t\tVALUES\n\t\t\t('0', '0', 'comment_moderation', 'Y', '5',' none', 20, 8, '_LANG_INST_BASE_VALUE88', 8)");
}
$oid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'comment_moderation'");
$gid = $wpdb->get_var("SELECT group_id FROM {$tableoptiongroups} WHERE group_name = 'General blog settings'");
$seq = $wpdb->get_var("SELECT MAX(seq) FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}'");
++$seq;
if (!$wpdb->get_row("SELECT * FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}' AND option_id = '{$oid}'")) {
$wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t(group_id, option_id, seq)\n\t\tVALUES\n\t\t('{$gid}', '{$oid}', '{$seq}')");
}
if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'auto'")) {
$wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}','auto', 'Automatic', NULL, NULL, 3)");
}
if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'none'")) {
$wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}', 'none', 'None', NULL, NULL, 1)");
}
if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'manual'")) {
$wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}', 'manual', 'Manual', NULL, NULL, 2)");
}
if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'moderation_notify'")) {
$wpdb->query("INSERT INTO {$tableoptions}\n\t\t\t(option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)\n\t\t\tVALUES\n\t\t\t('0', '0', 'moderation_notify' , 'Y', '2', '1', 20, 8, '_LANG_INST_BASE_VALUE89', 8)");
}
$oid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'moderation_notify'");
$seq = $wpdb->get_var("SELECT MAX(seq) FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}'");
++$seq;
if (!$wpdb->get_row("SELECT * FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}' AND option_id = '{$oid}'")) {
$wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t('{$gid}', '{$oid}', '{$seq}')");
}
// Get the title and ID of every post, post_name to check if it already has a value
$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM {$tableposts}");
foreach ($posts as $post) {
if ('' == $post->post_name) {
$newtitle = sanitize_title($post->post_title);
$wpdb->query("UPDATE {$tableposts} SET post_name = '{$newtitle}' WHERE ID = '{$post->ID}'");
}
}
$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM {$tablecategories}");
foreach ($categories as $category) {
if ('' == $category->category_nicename) {
$newtitle = sanitize_title($category->cat_name);
$wpdb->query("UPDATE {$tablecategories} SET category_nicename = '{$newtitle}' WHERE cat_ID = '{$category->cat_ID}'");
}
}
if (!$wpdb->get_var("SELECT option_name FROM {$tableoptions} WHERE option_name = 'permalink_structure'")) {
// If it's not already there
$wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)\n\t\t\tVALUES\n\t\t\t('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', '_LANG_INST_BASE_VALUE90', '8');");
}
if (!$wpdb->get_var("SELECT option_name FROM {$tableoptions} WHERE option_name = 'gzipcompression'")) {
// If it's not already there
$wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)\n\t\t\tVALUES\n\t\t\t('', '0', 'gzipcompression', 'Y', '2', '0', '20', '8', '_LANG_INST_BASE_VALUE91', '8');");
$optionid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'gzipcompression'");
$wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t(2, {$optionid}, 5)");
}
if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'hack_file'")) {
$wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t( `option_id` , `blog_id` , `option_name` , `option_can_override` , `option_type` , `option_value` , `option_width` , `option_height` , `option_description` , `option_admin_level` )\n\t\t\tVALUES\n\t\t\t('', '0', 'hack_file', 'Y', '2', '0', '20', '8', '_LANG_INST_BASE_VALUE92', '8')");
$optionid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'hack_file'");
$wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t(2, {$optionid}, 5)");
}
$wpdb->query("UPDATE {$tableoptionvalues} SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51");
// fix upload users description
$wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE37' WHERE option_id = 37");
// and file types
$wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE34' WHERE option_id = 34");
// add link to php date format. this could be to a wordpress.org page in the future
$wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE52' WHERE option_id = 52");
$wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE53' WHERE option_id = 53");
$wpdb->query("UPDATE {$tableoptions} SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')\n WHERE option_name LIKE 'links_rating_image%'\n AND option_value LIKE 'wp-links/links-images/%'");
$wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'comment_allowed_tags'");
$wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'use_preview'");
$wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'search_engine_friendly_urls'");
// Multiple categories
maybe_create_table($tablepost2cat, "\n\t\tCREATE TABLE `{$tablepost2cat}` (\n\t\t`rel_id` INT NOT NULL AUTO_INCREMENT ,\n\t\t`post_id` INT NOT NULL ,\n\t\t`category_id` INT NOT NULL ,\n\t\tPRIMARY KEY ( `rel_id` ) ,\n\t\tINDEX ( `post_id` , `category_id` )\n\t\t)\n\t\t");
$allposts = $wpdb->get_results("SELECT ID, post_category FROM {$tableposts}");
foreach ($allposts as $post) {
// Check to see if it's already been imported
$cat = $wpdb->get_row("SELECT * FROM {$tablepost2cat} WHERE post_id = {$post->ID} AND category_id = {$post->post_category}");
if (!$cat && 0 != $post->post_category) {
// If there's no result
$wpdb->query("\n\t\t\t\tINSERT INTO {$tablepost2cat}\n\t\t\t\t(post_id, category_id)\n\t\t\t\tVALUES\n\t\t\t\t('{$post->ID}', '{$post->post_category}')\n\t\t\t\t");
}
}
//.........这里部分代码省略.........
示例4: configure_ftp
function configure_ftp($form)
{
global $PLOGGER_DBH;
maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_host', "varchar(64) NOT NULL");
maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_user', "varchar(64) NOT NULL");
maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_pass', "varchar(64) NOT NULL");
maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_path', "varchar(255) NOT NULL");
$query = "UPDATE \"" . PLOGGER_TABLE_PREFIX . "config\" SET\n\t\t\"ftp_host\" = " . $PLOGGER_DBH->quote($form['ftp_host']) . ",\n\t\t\"ftp_user\" = " . $PLOGGER_DBH->quote($form['ftp_user']) . ",\n\t\t\"ftp_pass\" = " . $PLOGGER_DBH->quote($form['ftp_pass']) . ",\n\t\t\"ftp_path\" = " . $PLOGGER_DBH->quote($form['ftp_path']) . "";
run_query($query);
}
示例5: foreach
} else {
return false;
}
}
}
// we cannot directly tell that whether this succeeded!
foreach ($wpdb->get_col("DESC {$table_name}", 0) as $column) {
if ($column == $column_name) {
return false;
}
}
return true;
}
if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
include_once ABSPATH . '/wp-admin/upgrade-functions.php';
} elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
include_once ABSPATH . '/wp-admin/includes/upgrade.php';
} else {
die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
}
header('Content-type: text/html; charset=utf-8');
if (maybe_add_column($wpdb->downloads, 'file_hash', "ALTER TABLE {$wpdb->downloads} ADD file_hash varchar(40) NOT NULL default '' AFTER file_des;")) {
echo '<div style="margin:7em auto auto 10em;color:green;">成功添加file_hash列-_-!</div>';
} else {
die('<div style="margin:7em auto auto 10em;color:red;">添加列file_hash出错!</div>');
}
if (maybe_del_column($wpdb->downloads, 'file_category')) {
echo '<div style="margin:7em auto auto 10em;color:green;">成功删除file_category列,现在你可以使用 hacklog-downloadmanager了-_-!</div>';
} else {
die('<div style="margin:7em auto auto 10em;color:red;">删除列file_category出错!</div>');
}
示例6: VARCHAR
<?php
} else {
?>
<p><em>It doesn't look like your database information is incorrect. Please re-edit this file and double-check all the settings.</em></p>
<?php
}
break;
case 1:
?>
<h1>Step 1</h1>
<p>First let's get posts and comments.</p>
<?php
// For people running this on .72
$query = "ALTER TABLE `{$tableposts}` ADD `post_name` VARCHAR(200) NOT NULL";
maybe_add_column($tableposts, 'post_name', $query);
// Create post_name field
$connection = @mysql_connect($tp_database_host, $tp_database_username, $tp_database_password);
$database = @mysql_select_db($tp_database_name);
// For now we're going to give everything the same author and same category
$author = $wpdb->get_var("SELECT ID FROM {$tableusers} WHERE user_level = 10 LIMIT 1");
$category = $wpdb->get_var("SELECT cat_ID FROM {$tablecategories} LIMIT 1");
$posts = mysql_query('SELECT * FROM textpattern', $connection);
while ($post = mysql_fetch_array($posts)) {
// ID, AuthorID, LastMod, LastModID, Posted, Title, Body, Body_html, Abstract, Category1, Category2, Annotate, AnnotateInvite, Status, Listing1, Listing2, Section
$posted = $post['Posted'];
// 20030216162119
$year = substr($posted, 0, 4);
$month = substr($posted, 4, 2);
$day = substr($posted, 6, 2);
$hour = substr($posted, 8, 2);
示例7: eme_create_payments_table
function eme_create_payments_table($charset, $collate)
{
global $wpdb;
$db_version = get_option('eme_version');
$table_name = $wpdb->prefix . PAYMENTS_TBNAME;
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (\n id int(11) NOT NULL auto_increment,\n creation_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', \n booking_ids text NOT NULL,\n random_id tinytext NOT NULL,\n UNIQUE KEY (id)\n ) {$charset} {$collate};";
maybe_create_table($table_name, $sql);
} else {
maybe_add_column($table_name, 'random_id', "alter table {$table_name} add random_id tinytext NOT NULL;");
if ($db_version < 80) {
$payment_ids = $wpdb->get_col("SELECT id FROM {$table_name}");
foreach ($payment_ids as $payment_id) {
$random_id = eme_payment_random_id();
$sql = $wpdb->prepare("UPDATE {$table_name} SET random_id = %s WHERE id = %d", $random_id, $payment_id);
$wpdb->query($sql);
}
}
}
}
示例8: maybe_add_column
maybe_add_column(TABLE_PREFIX . 'albums', 'path', "varchar(255) NOT NULL");
maybe_add_column(TABLE_PREFIX . 'collections', 'path', "varchar(255) NOT NULL");
// add ip and approved fields to comments table
maybe_add_column(TABLE_PREFIX . 'comments', 'ip', "char(64)");
maybe_add_column(TABLE_PREFIX . 'comments', 'approved', "tinyint default 1");
maybe_add_column(TABLE_PREFIX . 'pictures', 'description', "text");
// user definable theme directory
maybe_add_column(TABLE_PREFIX . 'config', 'theme_dir', "varchar(128) NOT NULL");
// add support for user defined sort order for albums and collections
maybe_add_column(TABLE_PREFIX . 'config', 'album_sortby', "varchar(20) NOT NULL default 'id'");
maybe_add_column(TABLE_PREFIX . 'config', 'album_sortdir', "varchar(5) NOT NULL default 'DESC'");
maybe_add_column(TABLE_PREFIX . 'config', 'collection_sortby', "varchar(20) NOT NULL default 'id'");
maybe_add_column(TABLE_PREFIX . 'config', 'collection_sortdir', "varchar(5) NOT NULL default 'DESC'");
// add support for thumbnail configuration
maybe_add_column(TABLE_PREFIX . 'config', 'enable_thumb_nav', "tinyint default 0");
maybe_add_column(TABLE_PREFIX . 'config', 'thumb_nav_range', "int(11) NOT NULL default 0");
// insert default value (default theme directory)
$default_theme_dir = dirname(__FILE__) . "/" . 'themes/default/';
print "<li>Setting default theme directory to {$default_theme_dir}</li>";
$sql = 'UPDATE ' . TABLE_PREFIX . 'config SET `theme_dir` = \'' . $default_theme_dir . '\' WHERE 1';
mysql_query($sql);
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'comments ADD INDEX approved_idx (`approved`)';
mysql_query($sql);
// add ip and approved fields to comments table
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'comments CHANGE `date` `date` datetime';
mysql_query($sql);
/* // add field for timestamp refresh conditions
$sql = 'ALTER TABLE '.TABLE_PREFIX.'config
ADD (`small_lastmodified` datetime NOT NULL,
`large_lastmodified` datetime NOT NULL,
`rss_lastmodified` datetime NOT NULL)';
示例9: install
/**
* Installation function, creates tables if needed
**/
function install()
{
global $table_prefix, $wpdb;
/*wordpress tables*/
$table_users = $table_prefix . "users";
$table_categories = $table_prefix . "categories";
$table_pages = $table_prefix . "posts";
//post_status must be "static" or the post_type must be "page"
/*plugin tables*/
$table_groups = $table_prefix . "ug_Groups";
$table_groupsUsers = $table_prefix . "ug_GroupsUsers";
$table_groupsCategory = $table_prefix . "ug_GroupsCategory";
$table_groupsPage = $table_prefix . "ug_GroupsPage";
require_once ABSPATH . 'wp-admin/upgrade-functions.php';
/*Groups table*/
if (!userGroups::tableExists($table_groups)) {
$sql = "CREATE TABLE " . $table_groups . " (\r\n id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n name tinytext NOT NULL,\r\n homepage text,\r\n\t\tdescription text,\r\n UNIQUE KEY id (id)\r\n );";
dbDelta($sql);
} else {
//add a column for the group description (updates from 1.0RC1)
maybe_add_column($table_groups, "description", "ALTER TABLE {$table_groups} ADD description text;");
}
/*Groups-Users relation table*/
if (!userGroups::tableExists($table_groupsUsers)) {
$sql = "CREATE TABLE " . $table_groupsUsers . " (\r\n id_group bigint(20) UNSIGNED NOT NULL,\r\n id_user bigint(20) UNSIGNED NOT NULL,\r\n\t\t PRIMARY KEY(id_group, id_user)\r\n );";
dbDelta($sql);
}
/*Groups-Page relation table*/
if (!userGroups::tableExists($table_groupsPage)) {
$sql = "CREATE TABLE " . $table_groupsPage . " (\r\n id_group bigint(20) UNSIGNED NOT NULL,\r\n id_page bigint(20) UNSIGNED NOT NULL,\r\n exc_read tinyint(1) NOT NULL,\r\n exc_write tinyint(1) NOT NULL,\r\n\t\t PRIMARY KEY(id_group, id_page)\r\n );";
dbDelta($sql);
}
/*other plugins support table*/
$table_groupsGeneric = $table_prefix . "ug_GroupsGeneric";
if (!userGroups::tableExists($table_groupsGeneric)) {
$sql = "CREATE TABLE " . $table_groupsGeneric . " (\r\n\t\t\t\t\tid_group bigint(20) UNSIGNED NOT NULL,\r\n\t\t\t\t\tid_resource bigint(20) UNSIGNED NOT NULL,\r\n\t\t\t\t\tpermission text NOT NULL,\r\n\t\t\t\t\tplugin_name VARCHAR(128) NOT NULL,\r\n\t\t\t\t\tdescription text,\r\n\t\t\t\t\tPRIMARY KEY(id_group, id_resource, plugin_name)\t\t\t\t\t\r\n\t\t\t\t);";
dbDelta($sql);
}
}
示例10: create_tables
/**
* Create OpenID related tables in the WordPress database.
*/
function create_tables()
{
global $wp_version, $wpdb, $openid;
if ($wp_version >= '2.3') {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
} else {
require_once ABSPATH . 'wp-admin/admin-db.php';
require_once ABSPATH . 'wp-admin/upgrade-functions.php';
}
// Create the SQL and call the WP schema upgrade function
$statements = array($this->sql['nonce_table'], $this->sql['assoc_table'], "CREATE TABLE {$this->identity_table_name} (\n uurl_id bigint(20) NOT NULL auto_increment,\n user_id bigint(20) NOT NULL default '0',\n url text,\n hash char(32),\n PRIMARY KEY (uurl_id),\n UNIQUE KEY uurl (hash),\n KEY url (url(30)),\n KEY user_id (user_id)\n )");
$sql = implode(';', $statements);
dbDelta($sql);
// add column to comments table
$result = maybe_add_column($this->comments_table_name, 'openid', "ALTER TABLE {$this->comments_table_name} ADD `openid` TINYINT(1) NOT NULL DEFAULT '0'");
if (!$result) {
$openid->log->err('unable to add column `openid` to comments table.');
}
// update old style of marking openid comments and users
$wpdb->query("update {$this->comments_table_name} set `comment_type`='', `openid`=1 where `comment_type`='openid'");
$wpdb->query("update {$this->usermeta_table_name} set `meta_key`='has_openid' where `meta_key`='registered_with_openid'");
}
示例11: upgrade
/**
Upgrade the database
*/
function upgrade()
{
global $wpdb, $wp_version, $wpmu_version;
// include upgrade-functions for maybe_create_table;
if (!function_exists('maybe_create_table')) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
$date = date('Y-m-d');
maybe_add_column($this->public, 'date', "ALTER TABLE `{$this->public}` ADD `date` DATE DEFAULT '{$date}' NOT NULL AFTER `active`;");
// let's take the time to check process registered users
// existing public subscribers are subscribed to all categories
$users = $this->get_all_registered('ID');
if (!empty($users)) {
foreach ($users as $user) {
$this->register($user);
}
}
// update the options table to serialized format
$old_options = $wpdb->get_col("SELECT option_name from {$wpdb->options} where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
if (!empty($old_options)) {
foreach ($old_options as $option) {
$value = get_option($option);
$option_array = substr($option, 3);
$this->subscribe2_options[$option_array] = $value;
delete_option($option);
}
}
$this->subscribe2_options['version'] = S2VERSION;
//double check that the options are in the database
require S2PATH . "include/options.php";
update_option('subscribe2_options', $this->subscribe2_options);
// upgrade old wpmu user meta data to new
if (isset($wpmu_version) || strpos($wp_version, 'wordpress-mu')) {
$this->namechange_subscribe2_widget();
// loop through all users
foreach ($users as $user) {
// get categories which the user is subscribed to (old ones)
$categories = get_usermeta($user, 's2_subscribed');
$categories = explode(',', $categories);
// load blogs of user (only if we need them)
$blogs = array();
if (count($categories) > 0 && !in_array('-1', $categories)) {
$blogs = get_blogs_of_user($user, true);
}
foreach ($blogs as $blog_id => $blog) {
switch_to_blog($blog_id);
$blog_categories = (array) $wpdb->get_col("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'category'");
$subscribed_categories = array_intersect($categories, $blog_categories);
if (!empty($subscribed_categories)) {
foreach ($subscribed_categories as $subscribed_category) {
update_usermeta($user, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category);
}
update_usermeta($user, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories));
}
restore_current_blog();
}
// delete old user meta keys
delete_usermeta($user, 's2_subscribed');
foreach ($categories as $cat) {
delete_usermeta($user, 's2_cat' . $cat);
}
}
}
}
示例12: cleverness_todo_install
function cleverness_todo_install()
{
global $wpdb, $userdata;
get_currentuserinfo();
$cleverness_todo_db_version = '1.3';
$table_name = $wpdb->prefix . 'todolist';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (\r\n\t id bigint(20) UNIQUE NOT NULL AUTO_INCREMENT,\r\n\t author bigint(20) NOT NULL,\r\n\t status tinyint(1) DEFAULT '0' NOT NULL,\r\n\t priority tinyint(1) NOT NULL,\r\n todotext text NOT NULL,\r\n\t\t assign int(10),\r\n\t\t progress int(3),\r\n\t\t deadline varchar(30),\r\n\t\t completed timestamp\r\n\t );";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
$welcome_text = __('Add your first To-Do List item', 'cleverness-to-do-list');
$results = $wpdb->insert($table_name, array('author' => $userdata->ID, 'status' => 0, 'priority' => 1, 'todotext' => $welcome_text));
$new_options = array('list_view' => '0', 'dashboard_author' => '0', 'todo_author' => '0', 'assign' => '1', 'show_only_assigned' => '1', 'view_capability' => 'publish_posts', 'add_capability' => 'publish_posts', 'edit_capability' => 'publish_posts', 'delete_capability' => 'manage_options', 'purge_capability' => 'manage_options', 'complete_capability' => 'publish_posts', 'assign_capability' => 'manage_options', 'view_all_assigned_capability' => 'manage_options', 'dashboard_number' => '10', 'priority_0' => __('Important', 'cleverness-to-do-list'), 'priority_1' => __('Normal', 'cleverness-to-do-list'), 'priority_2' => __('Low', 'cleverness-to-do-list'), 'show_deadline' => '0', 'show_dashboard_deadline' => '0', 'show_progress' => '0', 'email_assigned' => '0', 'show_completed_date' => '0', 'date_format' => 'm-d-Y', 'user_roles' => 'contributor, author, editor, administrator');
add_option('cleverness_todo_settings', $new_options);
add_option('cleverness_todo_db_version', $cleverness_todo_db_version);
}
$installed_ver = get_option('cleverness_todo_db_version');
if ($installed_ver != $cleverness_todo_db_version) {
if (!function_exists('maybe_create_table')) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
maybe_add_column($table_name, 'assign', "ALTER TABLE `{$table_name}` ADD `assign` int(10);");
maybe_add_column($table_name, 'deadline', "ALTER TABLE `{$table_name}` ADD `deadline` varchar(30);");
maybe_add_column($table_name, 'progress', "ALTER TABLE `{$table_name}` ADD `progress` int(3);");
maybe_add_column($table_name, 'completed', "ALTER TABLE `{$table_name}` ADD `completed` timestamp;");
update_option('cleverness_todo_db_version', $cleverness_todo_db_version);
delete_option('atd_db_version');
}
}
示例13: upgrade
/**
Upgrade the database
*/
function upgrade()
{
global $wpdb;
// include upgrade-functions for maybe_create_table;
if (!function_exists('maybe_create_table')) {
require_once ABSPATH . '/wp-admin/upgrade-functions.php';
}
$date = date('Y-m-d');
maybe_add_column($this->public, 'date', "ALTER TABLE `{$this->public}` ADD `date` DATE DEFAULT '{$date}' NOT NULL AFTER `active`;");
update_option('s2_version', S2VERSION);
// let's take this time to check whether any public subscribers
// are also registered users of the blog, and convert them
$check = $wpdb->get_results("SELECT {$wpdb->users}.ID FROM {$wpdb->users} INNER JOIN {$this->public} ON {$wpdb->users}.user_email = {$this->public}.email");
if (!empty($check)) {
foreach ($check as $user) {
$this->register($user);
}
}
}
示例14: upgrade
/**
Upgrade the database
*/
function upgrade()
{
global $wpdb;
// include upgrade-functions for maybe_create_table;
if (!function_exists('maybe_create_table')) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
$date = date('Y-m-d');
maybe_add_column($this->public, 'date', "ALTER TABLE `{$this->public}` ADD `date` DATE DEFAULT '{$date}' NOT NULL AFTER `active`;");
// let's take the time to check process registered users
// existing public subscribers are subscribed to all categories
$users = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
if (!empty($users)) {
foreach ($users as $user) {
$this->register($user);
}
}
// update the options table to serialized format
$old_options = $wpdb->get_col("SELECT option_name from {$wpdb->options} where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
if (!empty($old_options)) {
foreach ($old_options as $option) {
$value = get_option($option);
$option_array = substr($option, 3);
$this->subscribe2_options[$option_array] = $value;
delete_option($option);
}
}
$this->subscribe2_options['version'] = S2VERSION;
//double check that the options are in the database
require S2PATH . "include/options.php";
update_option('subscribe2_options', $this->subscribe2_options);
}
示例15: post_notification_install
function post_notification_install()
{
global $wpdb;
$t_emails = $wpdb->prefix . 'post_notification_emails';
$t_posts = $wpdb->prefix . 'post_notification_posts';
$t_cats = $wpdb->prefix . 'post_notification_cats';
//******************************************//
//** Create WPPRAEFIX_post_notification table **//
//******************************************//
if (!function_exists('maybe_create_table')) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
$sql = "CREATE TABLE {$t_emails} (\r\n\t\t\t\t id int( 11 ) NOT NULL auto_increment,\r\n\t\t\t\t email_addr varchar( 255 ) default NULL,\r\n\t\t\t\t gets_mail int( 11 ) default NULL,\r\n\t\t\t\t last_modified timestamp( 14 ) NOT NULL,\r\n\t\t\t\t date_subscribed datetime default NULL,\r\n\t\t\t\t act_code varchar( 32 ) default NULL,\r\n\t\t\t\t PRIMARY KEY ( id ) \r\n\t\t )";
maybe_create_table($t_posts, $sql);
$sql = "ALTER TABLE {$t_emails} ADD subscribe_ip INT UNSIGNED NOT NULL default 0";
maybe_add_column($t_emails, 'subscribe_ip', $sql);
//************************************************//
//** Create WPPRAEFIX_post_notification_posts table **//
//************************************************//
# Add new table
$sql = "CREATE TABLE {$t_posts} (\r\n\t\t\t\tpost_id bigint(20) NOT NULL default '0',\r\n\t\t\t\tnotification_sent int NOT NULL default '-1',\r\n\t\t\t\tPRIMARY KEY (post_ID)\r\n\t\t )";
maybe_create_table($t_posts, $sql);
//Always adding this later keeps the code simple..... (Added in 2.2)
$sql = "ALTER TABLE {$t_posts} ADD date_saved datetime NOT NULL default '0000-00-00 00:00:00'";
maybe_add_column($t_posts, 'date_saved', $sql);
//This is in an if-statement, because auf the insert-statement.
if ($wpdb->get_var("SHOW TABLES LIKE '{$t_cats}'") == NULL) {
$sql = "CREATE TABLE {$t_cats} (\r\n\t\t\t\t\tid int( 11 ) NOT NULL,\r\n\t\t\t\t\tcat_id bigint(20) NOT NULL \r\n\t\t\t )";
maybe_create_table($t_cats, $sql);
// Thanks to Karsten Tinnefeld for this nice query
$wpdb->query("INSERT\r\n\t\t\t\t\tINTO {$t_cats} (id, cat_id)\r\n\t\t\t\t\tSELECT id, 0\r\n\t\t\t\t\tFROM {$t_emails} e\r\n\t\t\t\t\tWHERE NOT EXISTS (SELECT 1 \r\n\t\t\t\t\t\t\t\t\t\tFROM {$t_cats} c \r\n\t\t\t\t\t\t\t\t\t\tWHERE c.id = e.id )");
}
//This actually belongs into the create statement but it's easyer to maintain this way
$index = array();
$indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_cats}");
foreach ($indexlist as $indexrow) {
$index[] = $indexrow->Column_name;
}
if (!in_array('id', $index)) {
$wpdb->query(" ALTER TABLE {$t_cats} ADD INDEX ( id )");
}
if (!in_array('cat_id', $index)) {
$wpdb->query(" ALTER TABLE {$t_cats} ADD INDEX ( cat_id )");
}
$index = array();
$indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_emails}");
foreach ($indexlist as $indexrow) {
$index[] = $indexrow->Column_name;
}
if (!in_array('gets_mail', $index)) {
$wpdb->query(" ALTER TABLE {$t_emails} ADD INDEX ( id , gets_mail )");
}
if (!in_array('email_addr', $index)) {
$wpdb->query(" ALTER TABLE {$t_emails} ADD INDEX ( email_addr )");
}
$index = array();
$indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_posts}");
foreach ($indexlist as $indexrow) {
$index[] = $indexrow->Column_name;
}
if (!in_array('notification_sent', $index)) {
$wpdb->query(" ALTER TABLE {$t_posts} ADD INDEX ( notification_sent )");
}
//}
//************************************************//
//** Add Options
//************************************************//
load_plugin_textdomain('post_notification', POST_NOTIFICATION_PATH_REL);
add_option('post_notification_show_content', 'no', 'Whether to mail the content', 'no');
add_option('post_notification_read_more', '...', 'What to put in more-tag-text', 'no');
add_option('post_notification_send_default', 'yes', 'Whether to send normal posts', 'no');
add_option('post_notification_send_private', 'no', 'Whether to send private posts', 'no');
add_option('post_notification_send_page', 'no', 'Whether to send private posts', 'no');
add_option('post_notification_hdr_nl', "n", 'What kind of header', 'no');
add_option('post_notification_from_email', get_option('admin_email'), 'The adress used as sender', 'no');
add_option('post_notification_from_name', '@@blogname', 'The name used as sender', 'no');
add_option('post_notification_subject', '@@blogname: @@title', 'The subject of the mail', 'no');
add_option('post_notification_url', '', 'The URl to the main page', 'no');
add_option('post_notification_template', "email_template.txt", 'The Template to use', 'no');
add_option('post_notification_maxsend', "20", 'Number of Mails to send at once.', 'no');
add_option('post_notification_pause', "10", 'Time between bursts of Mails', 'no');
add_option('post_notification_nervous', "360", 'Nervous finger option');
add_option('post_notification_nextsend', time(), 'When to send the next mail', 'yes');
add_option('post_notification_lastsend', time(), 'When to send the last mail was sent.', 'no');
add_option('post_notification_lastpost', time(), 'When the last post was published.', 'no');
add_option('post_notification_page_meta', 'no', 'Whether to add a link to Meta', 'yes');
//autoload is set to yes, because meta might need it.
add_option('post_notification_page_name', __('Subscribe to Posts', 'post_notification'), 'Name of the Post Notification page.', 'yes');
add_option('post_notification_uninstall', 'no', 'Uninstall on deaktivation', 'no');
add_option('post_notification_captcha', '0', 'Number of captcha-cahars', 'no');
add_option('post_notification_lock', 'file', 'Lockingtype', 'yes');
add_option('post_notification_filter_include', 'yes', 'Include PN via filters', 'yes');
add_option('post_notification_selected_cats', '0', 'The category preselection list.', 'no');
add_option('post_notification_debug', 'no', 'Turn debugging on.', 'no');
add_option('post_notification_the_content_exclude', serialize(array()), 'Include PN via filters', 'no');
add_option('post_notification_empty_cats', 'no', 'Whether to show empty cats', 'no');
add_option('post_notification_show_cats', 'yes', 'Whether to show cats', 'no');
add_option('post_notification_subscribers', '0', 'Number of Subscibers', 'yes');
add_option('post_notification_auto_subscribe', 'yes', 'Auto Subscribe when regist new user', 'no');
if (is_dir(POST_NOTIFICATION_PATH . WPLANG)) {
//.........这里部分代码省略.........