Hi
Here's a couple of tips when starting out with a bit of Wordpress development. What I need to do is add a check within a plugin. Take a look here How to connect to the database from inside Wordpress for the code you need.
Here's a couple of tips that I've had to find out.
* firstly you may need to declare the $wpdb; object above your call to the database
Secondly
why cant i use % in wpdb prepare statement
why cant i use percentage sign in wpdb prepare statement
in a LIKE statement just double up the %%
ie
$tweet_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->options WHERE option_name LIKE '%_transient_twp_%' ;" ) );
will be
$tweet_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->options WHERE option_name LIKE '%%_transient_twp_%%' ;" ) );
No comments:
Post a Comment