Why my query does not run with prepare

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

DB_HOST – is LOCALHOST speedy than domain name? [closed]

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.

What does the $posts_join filter join to?

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.

WordPress wpdb->insert returns int(0) => doesn’t insert anything, no errors!

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

Use variable in SQL statement

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

How do I get my suggest to only suggest one taxonomy?

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

prepare function sql safe method

Both methods are okay ($new_wpdb->insert actually uses $new_wpdb->prepare) and provide the same level of safety when it comes to SQL escaping. $new_wpdb->insert is the preferred method unless you’re writing your own custom SQL query.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)