New answers tagged

2

The direct answer to the question "Is there a way to get 3+ dimensional array from a single MySql command" would be yes, sort of - WordPress routinely stores and retrieves multidimensional data from MySQL rows by serialize()ing and unserialize()ing structured data to/from a string format, so it's certainly possible using WordPress's database interaction ...


0

Why did it happen? It's hard to tell for sure because there are lots of variables to consider: mistakes made in exporting or importing, MySQL version etc. This is rather specific MySQL database question and doesn't have much to do with WordPress itself. To get a specific non-speculative answer to question why, I suggest to ask it in SO or DBA with plenty ...


0

I haven't tested this, but this should give you the count of skus for each post_id: SELECT post_id, COUNT(`post_id`) AS sku_count FROM `wp_postmeta` WHERE `meta_key` LIKE '%sku%' GROUP BY `post_id` To have it return only rows where the count is greater than one is trickier. Off the top of my head I'd probably use the above as a subquery: SELECT * from ...


0

you can export tables of your database that you want to transfer, and Import to another database, then you should change Prefixes of those .


1

Because $pageposts is an array of post IDs, but you need to pass a post object to setup_postdata - pull the objects instead: SELECT $wpdb->posts.* [rest of query] Note that, since you're not paginating, you don't need SQL_CALC_FOUND_ROWS


5

For the permanent solution, your SQL query is slightly off - you need: UPDATE db1357924680.wp_posts SET post_content = REPLACE( post_content, '[print_me]', '' ) WHERE post_content LIKE '%[print_me]%' MySQL replace example


3

There is an easier way to do this: add_filter( 'the_content', 'my_post_content_remove_shortcodes', 0 ); function my_post_content_remove_shortcodes( $content ) { /* Create an array of all the shortcode tags. */ $shortcode_tags = array( 'shortcode_1', 'shortcode_2', 'shortcode_3' ); /* Loop through the shortcodes and ...


0

if($search->keyword){ $project_args['s'] = $search->keyword; } That was the culprit. FML! Everything else was correct.


0

For this I use WP-CLI because I find it the easiest and it takes care of serialized data. wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid There is also an option that writes your changes into an SQL file instead of manipulating the actual database: wp search-replace foo bar --export=database.sql


0

I reviewed Wordpress' advice on phpMyAdmin and it seems I was adding one extra step which was causing the problem – ticking Add CREATE DATABASE / USE statement. Exporting without checking this box and results in SQL that imports without any problems.


2

Your wp_comments table already has a comment with id "1". You will need to remove the existing entries. If you want to keep them, then remove the "id" field from all comments you're importing.


0

Well, the error message kinda explains itself. The plugin probably want to create some tables but your woedpress user, the one indicated in wp-config.php, do not have a table create permissions. You will have to go into your MySQL administration panels and give the user the create permission as well.


0

@Romulus Since you are using Wordpress, I would highly suggest using Wordpress' functionality as much as you can. I would recommend using PHP and creating your own plugin or some kind of script that you can run. There are lots of tutorials out there that will give you the bare-bones implementation for creating a simple WordPress plugin. For now I'll run ...


0

To get a specific post in WordPress, you can use the get_post() function and get_the_category() to get the categories associated with it. You can then use the code found in this answer to dump the SQL queries used: $GLOBALS['wpdb']->last_query.


0

The number of tables is not an issue by itself. Actually separating the tables for each blog make each operation related to a specific blog more performant. Your scaling problem will come more likely from the big monolithic users tables. Scaling issues will come from the amount of requests your DB will have to handle, not the actual organization of the ...



Top 50 recent answers are included