[wp-hackers] MySQL View of every posts in a WP network
Louy
louy08 at gmail.com
Wed Nov 23 13:51:43 UTC 2011
hmmm... i don't guess a view would be possible, you might want to try
something like this:
> <?
> $blog_list = get_blog_list( 0, 'all' );
> $sql = '';
> foreach ($blog_list AS $blog) {
> $table = $wpdb->prefix.$blog['blog_id'].'_posts';
> $sql .= "(SELECT * from {$table} where ...)" .
" UNION ";
}
> $sql = substr($sql, 0, -7);
P.S. I didn't test this.
http://codex.wordpress.org/WPMU_Functions/get_blog_list
http://stackoverflow.com/questions/409705/mysql-selecting-data-from-multiple-tables-all-with-same-structure-but-differen
On Wed, Nov 23, 2011 at 1:07 PM, Carlo Gandolfo <carlo at artilibere.com>wrote:
> Hello everybody,
> I got a WP network whose posts tables are named:
>
> > wp_1_posts
> > wp_2_posts
> > wp_3_posts
> > ...
> > wp_n_posts
> >
>
>
> and I wish to build a view in MySql to gather all the contents (with limit
> 20) in a single block.
> That could be very useful to query and filter without having to loop
> through php.
>
> Anybody has hints to do that?
>
> Thank a lot,
> Carlo
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
Louy Alakkad
A web developer
about.me/louy
More information about the wp-hackers
mailing list