Understanding WordPress Search

The default search is handled by WP_Query mostly by a method called parse_search(), which is triggered by the s parameter. You can search the source of WP_Query for is_search and piece together a few other bits and pieces. Or you can just create a query… $s = new WP_Query(array(‘s’ => ‘test’)); … dump the SQL… … Read more

$wpdb->get_var – What value is returned when zero records are found?

First, you’re using prepare() wrong. Should be this: $wpdb->prepare(“SELECT Active FROM testers WHERE user_id = %s”, $user_id) Or even better (%d) represents numeric value as oppose to %s which is string: $wpdb->prepare(“SELECT Active FROM testers WHERE user_id = %d”, $user_id) If you have any debugging enabled, it will throw an error from your code. Which … Read more

How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category

Addition note and warning: always always always take backups before doing anything in your database. It’s very easy to do something you didn’t mean to and lose tons of data, especially when dealing with DELETE statements. Also, if your database is using InnoDB for the database engine, you can use transactions via BEGIN, ROLLBACK, and … Read more

AWS RDS connection limits

AWS RDS max_connections limit variable is based on Instance type, so you can upgrade your RDS or make more replica. The RDS types with max_connections limit: t2.micro 66 t2.small 150 m3.medium 296 t2.medium 312 m3.large 609 t2.large 648 m4.large 648 m3.xlarge 1237 r3.large 1258 m4.xlarge 1320 m2.xlarge 1412 m3.2xlarge 2492 r3.xlarge 2540 Referring by max_connections … Read more

phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’

From what I can see, you are inserting data in table wp_commentmeta. However the column meta_id has a Primary Key restriction. You can see the table definition at http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta As meta_id has a Primary Key restriction, this column may only hold unique values. The insert statements you have posted show only unique values for meta_id, … Read more

How to split the WordPress database?

Coming from a different angle, have you looked into adding indexes to the relevant tables to maximize efficiency? Sometimes the right index can make an amazing difference, even when the files aren’t particularly large. When they are as big as yours the difference could be all you need. You mentioned that you host the server … Read more

Issue with data array format

Your code looks good though. But Try the following approach – $current_date = $_POST[‘current_date’]; $current_date = date( ‘Y-m-d’, strtotime($current_date) ); $post_id = (int) $_POST[‘post_id’]; $query = $wpdb->prepare( “SELECT start_date FROM {$wpdb->prefix}booking_history WHERE start_date=%s AND post_id=%d”, $current_date, $post_id ); /* get_col used to retrieve column records */ $results = $wpdb->get_col( $query ); echo ‘<pre>’; print_r( $results … Read more

Adding data to custom wordpress database table

WordPress doesn’t work this way. If you want to work with a framework like WordPress, you should obey its rules! Of course you can add a database record like this, but it is a really bad approach. Try some plugins for creating and saving forms in WordPress like Ninja Forms or Quform. You can even … Read more