本文整理汇总了PHP中add_clean_index函数的典型用法代码示例。如果您正苦于以下问题:PHP add_clean_index函数的具体用法?PHP add_clean_index怎么用?PHP add_clean_index使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_clean_index函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_101
function upgrade_101()
{
global $wpdb;
// Clean up indices, add a few
add_clean_index($wpdb->posts, 'post_name');
add_clean_index($wpdb->posts, 'post_status');
add_clean_index($wpdb->categories, 'category_nicename');
add_clean_index($wpdb->comments, 'comment_approved');
add_clean_index($wpdb->comments, 'comment_post_ID');
add_clean_index($wpdb->links, 'link_category');
add_clean_index($wpdb->links, 'link_visible');
}
示例2: 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');
}
示例3: step3
function step3()
{
global $wpdb;
do_action('import_start');
set_time_limit(0);
update_option('ljapi_step', 3);
echo '<div id="ljapi-status">';
echo '<h3>' . __('Threading Comments…') . '</h3>';
echo '<p>' . __('We are now re-building the threading of your comments (this can also take a while if you have lots of comments)...') . '</p>';
ob_flush();
flush();
// Only bother adding indexes if they have over 5000 comments (arbitrary number)
$imported_comments = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_type = 'livejournal'");
$added_indices = false;
if (5000 < $imported_comments) {
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
$added_indices = true;
add_clean_index($wpdb->comments, 'comment_type');
add_clean_index($wpdb->comments, 'comment_karma');
add_clean_index($wpdb->comments, 'comment_agent');
}
// Get LJ comments, which haven't been threaded yet, 5000 at a time and thread them
while ($comments = $wpdb->get_results("SELECT comment_ID, comment_agent FROM {$wpdb->comments} WHERE comment_type = 'livejournal' AND comment_agent != '0' LIMIT 5000", OBJECT)) {
foreach ($comments as $comment) {
$wpdb->update($wpdb->comments, array('comment_parent' => $this->get_wp_comment_ID($comment->comment_agent), 'comment_type' => 'livejournal-done'), array('comment_ID' => $comment->comment_ID));
}
wp_cache_flush();
$wpdb->flush();
}
// Revert the comments table back to normal and optimize it to reclaim space
if ($added_indices) {
drop_index($wpdb->comments, 'comment_type');
drop_index($wpdb->comments, 'comment_karma');
drop_index($wpdb->comments, 'comment_agent');
$wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
}
// Clean up database and we're out
$this->cleanup();
do_action('import_done', 'livejournal');
if ($imported_comments > 1) {
echo '<p>' . sprintf(__("Successfully re-threaded %s comments."), number_format($imported_comments)) . '</p>';
}
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
echo '</div>';
}
示例4: upgrade_101
function upgrade_101()
{
global $wpdb, $tableoptionvalues, $tablelinkcategories, $tableposts, $tablecategories, $tablecomments, $tablelinks;
// Fix possible duplicate problem from CVS
$option59 = $wpdb->get_results("SELECT * FROM {$tableoptionvalues} WHERE option_id = '59'");
if (1 < count($option59)) {
$wpdb->query("DELETE FROM {$tableoptionvalues} WHERE option_id = '59' AND optionvalue LIKE('%FROM order%')");
}
// Remove 'automatic' option for comment moderation until it actually does something
$wpdb->query("DELETE FROM {$tableoptionvalues} WHERE optionvalue = 'auto'");
// Less intrusive default
$wpdb->query("ALTER TABLE `{$tablelinkcategories}` CHANGE `show_description` `show_description` ENUM( 'Y', 'N' ) DEFAULT 'N' NOT NULL");
// Clean up indices, add a few
add_clean_index($tableposts, 'post_name');
add_clean_index($tableposts, 'post_status');
add_clean_index($tablecategories, 'category_nicename');
add_clean_index($tablecomments, 'comment_approved');
add_clean_index($tablecomments, 'comment_post_ID');
add_clean_index($tablelinks, 'link_category');
add_clean_index($tablelinks, 'link_visible');
}