Tag Info

Hot answers tagged

2

Since version 3.9 (that will be released soon, actually in beta 2) WordPress will use mysqli to connect to database (3.9- versions use mysql) so you can actually use new wpdb instances and helper function to connect externa values from WordPress. What I suggest is to configure external database using constants in wp-config.php in this way you are sure that ...


2

A key must be defined for a table by using a single column, or multiple. So on your code, you need to a line to the sql KEY id (id) - $sql = "CREATE TABLE $table_name ( id int NOT NULL AUTO_INCREMENT, feedurl text NOT NULL, category text NOT NULL, KEY id (id) );";


2

You want the query to look like this: SELECT email FROM wp_my_users WHERE email = 'mail@example.com' instead of this: SELECT email FROM 'wp_my_users' WHERE email = 'mail@example.com' So try to construct your query with: $sql = "SELECT email FROM {$my_table_name} WHERE email = %s"; $result = $wpdb->get_var( $wpdb->prepare( $sql, $email_address ...


1

First, you're using prepare() wrong. Should be this: $wpdb->prepare("SELECT Active FROM testers WHERE user_id = %s", $user_id) If you have any debugging enabled, it will throw an error from your code. Which may make your location header not work properly. Second, the get_var() function indeed returns null when there are no results. Third, setting a ...


1

Why not use get_comments(), instead of trying to roll your own with $wpdb? function display_sitewide_comments() { $sites = wp_get_sites(); $network_comments = array(); $max = 20; foreach( $sites as $site ) { switch_to_blog( $site->blog_id ); $args = array( 'number' => $max, 'status' => ...


1

the _edit_lock is generated each time you edit a post or page. it consist the timecode and the user. so WordPress is knowing who is currently editing it. meta_id post_id meta_key meta_value 9 5 _edit_lock 1388386997:1 if you manipulate it WordPress reacts somehow sensitive ...I tried to fetch how many seconds somebody ...


1

Read the wpdb docs and don't forget to protect your query: global $wpdb; $table_name = $wpdb->prefix . "item"; $login_name = sanitize_user( $_POST['login_name'] ); //assuming you're dealing with username $prepare = $wpdb->prepare( "SELECT * FROM $table_name WHERE uname = %s", $login_name ); $myrows = $wpdb->get_results( $prepare ); //output ...


1

Yes 90-100ms round trip + time to prepare SQL statement + time to execute statement + time to send results back multiplied by the number of times you need to query the database. Sure the connection may stay open but it's an inherently expensive thing to do. Considering that some setups can respond in full in less than 100ms never mind the database ...



Only top voted, non community-wiki answers of a minimum length are eligible