writing inner join in wpdb

thanks for your time and thanks to @czerspalace I started the query with double quotation and then separate it with a single quotation and after looking at the echo output I found that there’s no spaces between From and table name this is the correct way $pending_reservations = $wpdb->get_results(‘ SELECT booking_calendars.cal_name FROM ‘.$wpdb->prefix.’booking_calendars AS booking_calendars … Read more

MySQL crashed because of the large number of requests

MySQL shouldn’t crash because of queries like those, but it could feel like it does because your site won’t work. I’d first run SELECT option_name, length(option_value) FROM wp_options WHERE autoload = ‘yes’ ORDER BY length(option_value) DESC; to see if some option has accumulated a large value (I’ve seen wp-cron entries grow very large in one … Read more

Join new table with SQL query

Always escape/prepare your data Don’t leave it open to injections: global $wpdb; $all_posts = $wpdb->get_results( $wpdb->prepare( ” SELECT %s.* FROM %s LEFT JOIN %s ON(%s = %s) WHERE %s=”soundcloud” AND %s=”%s” ” ,$wpdb->posts ,$wpdb->posts ,”{$wpdb->prefix}soundcloud” ,$wpdb->posts.ID ,”{$wpdb->prefix}soundcloud.idpost” ,$wpdb->posts.post_type ,$wpdb->posts.post_name ,$name ), OBJECT ); echo ‘<pre>’.var_export( $all_posts, true ).'</pre>’; Use the prefix $wpdb; offers the $wpdb->prefix, … Read more

HTML Entities in Post Title

It seems like the crux of the question is this: This causes the first ‘if’ condition to return TRUE and it inserts a duplicate post. Check for the post_name instead. That value is normalized to lowercase and dashes by sanitize_title_with_dashes so you won’t have this issue. That value is also the one that WordPress enforces … Read more

Error while importing database

When exporting from original database you should choose to create the tables if they dosn’t exist (First error). If you didn’t choose that option (in phpMyAdmin that option exists, not sure in other database tools), the import file can not create the tables for your and you need to create then prior to start importing … Read more

Rewrite database urls

Try this plugin: http://wordpress.org/extend/plugins/search-and-replace/ – It helped me dozens of times. Or try this query: UPDATE tablename SET tablefield = replace(tablefield, “findstring”, “replacestring”); Or try this method, dump the database, open the SQL file, do a find and replace in a text editor then reimport it. Take care to backup your database prior to making … Read more

wpdb insert and boolean fields

BOOL or BOOLEAN are as far as MYSQL is concerned just replacements/synonyms for TINYINT(1), tiny integer, so using %d for integers is the correct way to do it. Some additional information: Codex: Class Reference – wpdb – Placeholders MySQL: Numeric Type Overview MySQL: Boolean Literals MySQL: Integer Types

WP_USE_EXT_MYSQL

This constant is actually never defined in core code at all. You can define it yourself in wp-config.php configuration if you need to, but core doesn’t need it defined for normal operation. It only exists for re–configuring into running untypical setup.