[wp-hackers] $wpdb cacheing?
Otto
otto at ottodestruct.com
Tue Aug 21 18:15:05 GMT 2007
Caching is not your problem. Although it will be, eventually.. ;)
get_pages contains this:
$query = "SELECT * FROM $wpdb->posts " ;
$wpdb->posts is set in wp-settings.php. It uses the prefix there, but
not later. So you'll need to change $wpdb->posts and probably other
$wpdb->tablename variables as well.
Also, get_pages does use the $wp_object_cache global, so if you have
object caching on, you'll get from the cache instead of making the
database call. The easy solution to this is simply to flush the cache
by calling wp_cache_flush() before making the call. Or just not enable
the object cache to begin with.
The memory cache isn't used with a get_pages() call.
On 8/19/07, Stephen Rider <wp-hackers at striderweb.com> wrote:
> Hi --
>
> I'm trying to make a function that gets a combined list of Pages from
> two different blogs (both in the same database)
>
> Since the login info is the same, it occurred to me to try changing
> the table prefix to get the second blog's data. Here's the code:
>
> $mbpages1 = get_pages( $args );
> $orig_prefix = $wpdb->prefix;
> $wpdb->prefix = 'blah_';
> $mbpages2 = get_pages( $args );
> $mbpages1 = array_merge( $mbpages1, $mbpages2 );
> $wpdb->prefix = $orig_prefix;
>
> It pulls the first blog's data twice.
>
> Is the get_pages being cached somehow? Is there a way to reset the
> cache so it pulls the different data?
>
> ...and if I do that, is there a way for me to cache the combined list
> and thus avoid a big performance hit?
>
> My head hurts. Thanks in advance.
>
> Stephen
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list