Clean up very big and very dirty database
Yes, it is safe but always prefer a database backup before. You can also try the Minimise WordPress DB queries to clean more.
Yes, it is safe but always prefer a database backup before. You can also try the Minimise WordPress DB queries to clean more.
That is not how $wpdb->prepare works. You feed prepare a string with sprintf-like placeholders, and the appropriate replacement values. Placeholders The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. (The %s and %d placeholders have been available since the function was added to core in … Read more
prepare accepts three placeholder arguments— ” %s (string), %d (integer) and %f (float)”. You have used %i. That isn’t going to get through the sanitization process. That is why you are getting 0. You need %d instead.
Usually you only have to use mysql.domain.com if connecting to a remote database. If that is what you are doing, then yes. It will be slower than a locally hosted database. Even if the domain resolves to the local server localhost should resolve quicker as it uses the loopback interface which bypasses network hardware.
posts_join is only a part of the full SQL query, the table you’re joining to is referenced earlier in the query. You can see the full query with the posts_request filter. See the documentation for the rest of the query filters.
In general, custom SQL queries are faster than the WordPress native funtions regardless. The real question is, are these custom SQL queries better, and the simple answer is “NO”. Lets look at a few important points to why not to use custom SQL queries: You loose all filters, in the case of WP_Query, you loose … Read more
Your format is wrong. On your code is should be $insertion = $wpdb->insert($wpdb->prefix . ‘table-name-of-plugin’, array( ‘column-name’ => $stringValueForC1, ‘second-column-name’ => $stringValueForC2 ), array(‘%s’, ‘%s’) ); Notice the change from array(‘%s, %s’) to array(‘%s’, ‘%s’) Also, since you are setting the format for both of the value as string. I recommend that you just use … Read more
Firstly, as a PHP rule, you don’t need to echo a variable when doing a string concatenation. Secondly, you need to prepare your query when adding a variable inside. So your query would become like this: $prepared = $wpdb->prepare( “SELECT meta_value FROM wp_woocommerce_order_itemmeta WHERE meta_key = ‘_wc_checkout_add_on_label’ AND order_item_id = %s”, $orderID ); $size = … Read more
After join term_id exist two times. You should specify which term_id you are querying by prefixing full table name (or alias). Also there is a other error term_taxonomy.term_id = terms.term_id missing table prefix. So the updated query will look like $query = ‘SELECT term_taxonomy_id, ‘ . $wpdb->prefix . ‘terms.term_id, taxonomy, name FROM ‘ . $wpdb->term_taxonomy … Read more
Per comments above from mmm Try this $posts = get_posts([“s” => “string to search”]); Also, Covering the get_posts API is a bit beyond a single StackExchange answer, but if you want to dive deep you’ll find more informations in the codex.