WordPress database error: [Query was empty] [closed]
WordPress database error: [Query was empty] [closed]
WordPress database error: [Query was empty] [closed]
Here’s one way by using wpdb::get_col() and fetch the id column: $pids = $wpdb->get_col( “SELECT id FROM my_table” ); We could then clean it by integer convert each id with: $pids = wp_parse_id_list( $pids ); Just note the different max value for intval(), depending on 32 or 64 bits systems.
You’ll need to loop through your posts, use get_comments_number() to get the number of comments for each post, and then accumulate the total number of comments in a separate variable. e.g.: <?php $features_comment_count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $features_comment_count += get_comments_number(); endwhile; endif; ?> (I’ll assume that … Read more
I agree with @bainternet. You don’t need $wpdb->prepare. There isn’t any user supplied content. The answer to the question is that to get a wildcard % to pass through prepare you need to double it in your code. LIKE ‘_transient_wb_tt_%%’ Try that or this if you want a good look at the generated query: var_dump($wpdb->prepare(” … Read more
Whenever I’m trying to link two sites, I find the most efficient and least destructive way is to use the WordPress XMLRPC API. http://codex.wordpress.org/XML-RPC_WordPress_API/Posts In this case, you could pull this info through using the built in IXR_Client library. This saves a ton of time writing code and trying to mix databases. If they wind … Read more
Your code looks okay, and considering you are not submitting user entered data, the prepare() method isn’t required, but as a matter of best-practice it’s good to learn how it works and use it consistently. With that said, using the prepare() method, your code would look like this: $sql = $wpdb->prepare( ” SELECT ID FROM … Read more
After much trial and error I finally figured out a solution using mysqli. I consider it a acceptable solution since the query will only be run on plugin updates. $mysqli = new mysqli(); $mysqli->connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $sql = ” DROP TRIGGER IF EXISTS {$wpdb->get_blog_prefix($site->id)}post_queue_insert; CREATE TRIGGER {$wpdb->get_blog_prefix($site->id)}post_queue_insert BEFORE INSERT ON {$wpdb->get_blog_prefix($site->id)}posts FOR EACH ROW … Read more
The solution given by @RolandoMySQLDBA will give you all posts because you have a * and not a +. The * means to return zero or more matches, which is not what you want. In this case, you actually don’t need either, but just to match the first character. Try this: $sql .= $wpdb->prepare( ” … Read more
WordPress uses this feature of MySQL to get a total count of posts when you are only retrieving limited amount (100 posts total, but only 10 posts per page). From quick look at source there is no_found_rows query argument that can disable it. That will wreck pagination and should only be used with specific queries … Read more
It may be possible. A lot of the core API that deals with logins and cookies is pluggable. You could replace wp_set_current_user with something that queried your external database rather than the internal one, for instance. Authentication is already done via a the authenticate filter (wp_authenticate is the function that does this, and the filter … Read more