Tag Info

New answers tagged

0

By using the query method, you may risk a sanitization problem. By using the update method, you risk a race condition. To overcome both, just before update issue a select on the row with a final clause "FOR UPDATE". For fetching the results you can use the same condition which you are going to use for update and get_row method. The only caveat being if your ...


0

The granularity of data in your example suggests that custom field (more so one with multiple values) would be wrong choice in first place. Think about it like this: only one dog might weight precisely 35.5kg — that is type of data appropriate for custom field multiple dogs (or dog breeds) might be of medium weight — that is type of data appropriate for ...


2

Try to replace: AND meta_value LIKE %s with AND meta_value LIKE '%%%s%%' so your SQL will become: AND meta_value LIKE '%The%' instead of: AND meta_value LIKE 'The'


0

The problem occurs in MySQL 5.6.20 or later, if the innodb_log_file_size in the my.ini is set too low. I changed mine to 16M and the problem went away. Thanks to @Otto for the solution. http://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-20.html


0

I'm currently dealing with a site using W3TC plugin and that plugin seems to provide a custom database handler which actually caches queries to memcache. Give that a try. Sidenote: Just make sure, in case you are using multiple production servers, to use a shared memcache server and that you don't cache those queries on local memcache server (that's what my ...


0

Why not just orderby your ShowPostByVotes query in the (1) custom query? Are they accessible to each other?


0

If you want to perform a single query that retrieves one field but for multiple results (e.g. to avoid round-trips to the database), the simplest explanation is to use get_results() instead. Taking your query: $wpdb->get_var( $wpdb->prepare("SELECT `meta_value` FROM `wp_usermeta` WHERE `meta_key` = 'first_name' and `user_id` = %d ", ...


1

Why do your own database queries? Use the WP functions to do it for you. $empid = (int) $_REQUEST['empid']; $name = get_user_meta($empid, 'first_name', true) . ' ' . get_user_meta($empid, 'last_name', true);


0

I found the answer my self. First open your wp-config.php and check the bottom of file that Is that contain the below code?... if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); If yes then add the below code to make the connection in your plugin PHP files to connect with wp-config.php file that contain Database Name, Database ...


1

Firstly, you could and should use wpdb to connect to another database. E.g. like this: $the_other_db = new wpdb( 'username', 'password', 'database', 'localhost' ); $results = $the_other_db->get_results( $sql ); Take a look at Using wpdb to connect to a separate database for more information. Secondly, like @AndrewBartel said it's ...



Top 50 recent answers are included