Tag Info

Hot answers tagged

2

As you can see in source code the = sign is hardcoded in the wpdb::update() method, so, by default, is not possible to use IN for update method. Simplest way to do the trick is to use the wpdb::query() with your sql query, just be sure to properly escape all values Example: function wpdb_update_in( $table, $data, $where, $format = NULL, $where_format = ...


1

This is a php logic / variable issue. You output $fullname whether or not it has been set inside that iteration's foreach. So for projects that never enter the foreach to set $fullname, it still contains whatever the last iteration had set it to. Set it to an empty string before the foreach so it only contains a name if it enters the foreach.


1

Yes you can. Straight from the codex The $wpdb object is not limited to the default tables created by WordPress; it can be used to read data from any table in the WordPress database (such as custom plugin tables). For example to SELECT some information from a custom table called "mytable", you can do the following. $myrows = $wpdb->get_results( ...


1

These look like 2 separate questions. The first I think is a single vs double quotes issue: Try this: $html = ''; foreach ( $recent_across_network as $post ) { $html .= 'blog_id, '.$post->ID.' ) . '">' . $post->post_title . ''; } $html .= ''; The line in the foreach is putting $post->ID in single quotes which won't evaluate it's value but ...


1

Check out the codex on wpdb. In your case, get_row returns the first row of the result set as an object. There's no need for any mysqli_* functions when using $wpdb. if ( $result2 ) echo json_encode( $result2 ); And a heads up for SQL injection - use the prepare method: $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ...



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