<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>bbPress Support Forums Tag: BB_Query</title>
<link>http://bbpress.org/forums/</link>
<description>bbPress Support Forums Tag: BB_Query</description>
<language>en</language>
<pubDate>Fri, 09 Jan 2009 01:21:31 +0000</pubDate>

<item>
<title>hudatoriq on "Custom query in bbPress. Latest topics from several forums"</title>
<link>http://bbpress.org/forums/topic/custom-query-in-bbpress-latest-topics-from-several-forums#post-22039</link>
<pubDate>Sat, 20 Dec 2008 17:02:44 +0000</pubDate>
<dc:creator>hudatoriq</dc:creator>
<guid isPermaLink="false">22039@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;Thank you for your response. I'll take a deeper look into the BB_Query class.&#60;/p&#62;
&#60;p&#62;After reading this question, do you think of a plan to extend the bbPress live plugin so it can transport the query as well?&#60;br /&#62;
I think it's a great idea. Just my opinion :-)
&#60;/p&#62;</description>
</item>
<item>
<title>sambauers on "Custom query in bbPress. Latest topics from several forums"</title>
<link>http://bbpress.org/forums/topic/custom-query-in-bbpress-latest-topics-from-several-forums#post-22025</link>
<pubDate>Sat, 20 Dec 2008 13:55:08 +0000</pubDate>
<dc:creator>sambauers</dc:creator>
<guid isPermaLink="false">22025@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;Not possible using bbPress Live plugin I'm pretty sure. You would have to do separate calls and then merge them somehow.&#60;/p&#62;
&#60;p&#62;It's probably possible using the BB_Query class inside bbPress though.
&#60;/p&#62;</description>
</item>
<item>
<title>hudatoriq on "Custom query in bbPress. Latest topics from several forums"</title>
<link>http://bbpress.org/forums/topic/custom-query-in-bbpress-latest-topics-from-several-forums#post-21952</link>
<pubDate>Thu, 18 Dec 2008 20:20:23 +0000</pubDate>
<dc:creator>hudatoriq</dc:creator>
<guid isPermaLink="false">21952@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;Hi. I still don't quite familiar with bbPress custom query system. Is there a simple way to pull the latest topics from only specific forums? In WP we can pull posts from several categories using comma separated category IDs in the query. Can bbPress do that?&#60;/p&#62;
&#60;p&#62;And if there is, is it possible to pull it from WordPress using bbPress_Live php class in bbpress-live plugin?&#60;/p&#62;
&#60;p&#62;Thank you in advance.
&#60;/p&#62;</description>
</item>
<item>
<title>mrhoratio on "bb_query: get topics started within a date range?"</title>
<link>http://bbpress.org/forums/topic/bb_query-get-topics-started-within-a-date-range#post-16144</link>
<pubDate>Mon, 12 May 2008 05:21:26 +0000</pubDate>
<dc:creator>mrhoratio</dc:creator>
<guid isPermaLink="false">16144@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;Hey Sam, thanks for making a ticket for this. I was able to query for topics within a date from directly from Wordpress as well. Here's something I wrote to merge &#34;super sticky&#34; bbPress topics into the Wordpress loop. It's a bit of hack, but it brings the &#34;Promote to Front Page&#34; functionality of Drupal into Wordpress/bbPress:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php get_header(); ?&#38;gt;

&#38;lt;?php

//Put Wordpress posts into an array
$wp_posts = $posts;

if (!is_single()){

	//Retrieve first post of previous page (we need this post&#38;#39;s date to query bbPress topics
	$offset=$paged*$posts_per_page+$posts_per_page;
	$first_post_of_previous_page = get_posts(&#38;#39;numberposts=1&#38;#38;offset=&#38;#39;.$offset);

	//First set the start and end dates to limit the query to the bbPress table
	$startdate=(date(&#38;#39;YmdHis&#38;#39;,strtotime($first_post_of_previous_page[0]-&#38;gt;post_date_gmt)));

	//If it&#38;#39;s the most recent page, set end date to today
	if ($paged){
		$enddate=(date(&#38;#39;YmdHis&#38;#39;,strtotime($wp_posts[0]-&#38;gt;post_date_gmt)));
	} else {
		$enddate=gmdate(&#38;#39;YmdHis&#38;#39;);
	}

	//Retrieve &#38;quot;Super Sticky&#38;quot; topics from bbPress tables
	//This assumes your bbPress and Wordpress tables are in the same database
	$bb_topics = $wpdb-&#38;gt;get_results(&#38;quot;SELECT * FROM bb_topics WHERE topic_sticky = 2 AND topic_start_time BETWEEN $startdate AND $enddate ORDER BY topic_start_time DESC&#38;quot;);

	//Map bbPress topics to WordPress posts structure
	foreach($bb_topics as $bb_topic){
		$bb_first_post = $wpdb-&#38;gt;get_results(&#38;quot;SELECT post_text FROM bb_posts WHERE post_position = &#38;#39;1&#38;#39; AND topic_id = $bb_topic-&#38;gt;topic_id&#38;quot;, ARRAY_A);
		$bb_post-&#38;gt;ID = &#38;quot;forum_topic_&#38;quot;.$bb_topic-&#38;gt;topic_id;
		$bb_post-&#38;gt;post_author = $bb_topic-&#38;gt;topic_poster;
		$bb_post-&#38;gt;post_date = $bb_topic-&#38;gt;topic_start_time;
		$bb_post-&#38;gt;post_content = $bb_first_post[0][post_text];
		$bb_post-&#38;gt;post_title = $bb_topic-&#38;gt;topic_title;
		$bb_post-&#38;gt;post_status = &#38;quot;publish&#38;quot;;
		$bb_post-&#38;gt;comment_status = &#38;quot;open&#38;quot;;
		$bb_post-&#38;gt;ping_status = $bb_topic-&#38;gt;post_id;
		$bb_post-&#38;gt;post_name = &#38;quot;forums/topic/&#38;quot;.$bb_topic-&#38;gt;topic_slug;
		$bb_post-&#38;gt;post_type = &#38;quot;post&#38;quot;;
		$bb_post-&#38;gt;comment_count = $bb_topic-&#38;gt;topic_posts-1;

		//add bbPress topic to Wordpress posts array
		$wp_posts[] = $bb_post;

	};

	//Create function to sort array of posts by date
	function compare($x, $y){
		if ( $x-&#38;gt;post_date == $y-&#38;gt;post_date )
			return 0;
		else if ( $x-&#38;gt;post_date &#38;lt; $y-&#38;gt;post_date )
			return 1;
		else
			return -1;
	}

	//Sort array
	usort($wp_posts,&#38;#39;compare&#38;#39;);
}

?&#38;gt;

	&#38;lt;div id=&#38;quot;content-box&#38;quot; class=&#38;quot;span-8&#38;quot;&#38;gt;

		&#38;lt;div id=&#38;quot;content-area&#38;quot; class=&#38;quot;clearfix&#38;quot;&#38;gt;

&#38;lt;?php if ($wp_posts): ?&#38;gt;
	&#38;lt;?php foreach ($wp_posts as $post): ?&#38;gt;
		&#38;lt;?php setup_postdata($post); ?&#38;gt;

			&#38;lt;div class=&#38;quot;entry&#38;quot;&#38;gt;

				&#38;lt;div class=&#38;quot;entry-header clearfix&#38;quot;&#38;gt;

					&#38;lt;div class=&#38;quot;info span-2&#38;quot;&#38;gt;
						&#38;lt;a href=&#38;quot;&#38;lt;?php the_permalink(); ?&#38;gt;#comments&#38;quot; class=&#38;quot;comment-activity&#38;quot;&#38;gt;&#38;lt;?php comments_number(&#38;#39;&#38;lt;strong&#38;gt;Post comment&#38;lt;/strong&#38;gt;&#38;#39;, &#38;#39;&#38;lt;strong&#38;gt;1&#38;lt;/strong&#38;gt; Comment&#38;#39;, &#38;#39;&#38;lt;strong&#38;gt;%&#38;lt;/strong&#38;gt; Comments&#38;#39; );?&#38;gt;&#38;lt;/a&#38;gt;
					&#38;lt;/div&#38;gt;&#38;lt;!-- end info --&#38;gt;

					&#38;lt;div class=&#38;quot;content span-6 last&#38;quot;&#38;gt;
						&#38;lt;h2&#38;gt;&#38;lt;a href=&#38;quot;&#38;lt;?php the_permalink(); ?&#38;gt;&#38;quot; rel=&#38;quot;bookmark&#38;quot; title=&#38;quot;Permanent Link to &#38;lt;?php the_title(); ?&#38;gt;&#38;quot;&#38;gt;&#38;lt;?php the_title(); ?&#38;gt;&#38;lt;/a&#38;gt;&#38;lt;/h2&#38;gt;
					&#38;lt;/div&#38;gt;&#38;lt;!-- end content --&#38;gt;

				&#38;lt;/div&#38;gt;&#38;lt;!-- end entry-header --&#38;gt;

				&#38;lt;div class=&#38;quot;entry-content clearfix&#38;quot;&#38;gt;

					&#38;lt;div class=&#38;quot;info span-2 clearfix&#38;quot;&#38;gt;
						&#38;lt;p&#38;gt;&#38;lt;strong&#38;gt;&#38;lt;?php the_author() ?&#38;gt;&#38;lt;/strong&#38;gt;&#38;lt;br /&#38;gt;
						&#38;lt;?php the_time(&#38;#39;M j, Y&#38;#39;); ?&#38;gt;
						&#38;lt;/p&#38;gt;
						&#38;lt;p class=&#38;quot;share-this&#38;quot;&#38;gt;&#38;lt;?php akst_share_link(); ?&#38;gt;&#38;lt;/p&#38;gt;

						&#38;lt;p class=&#38;quot;post-comment&#38;quot;&#38;gt;&#38;lt;a href=&#38;quot;&#38;lt;?php the_permalink(); ?&#38;gt;#respond&#38;quot;&#38;gt;Comment&#38;lt;/a&#38;gt;&#38;lt;/p&#38;gt;

					&#38;lt;/div&#38;gt;&#38;lt;!-- end info --&#38;gt;

					&#38;lt;div class=&#38;quot;content span-6 last clearfix&#38;quot;&#38;gt;

						&#38;lt;?php the_content(&#38;#39;Click to continue&#38;#39;); ?&#38;gt;

						&#38;lt;p class=&#38;quot;entry-tags&#38;quot;&#38;gt;&#38;lt;?php the_tags(&#38;#39;&#38;lt;strong&#38;gt;Posted in: &#38;lt;/strong&#38;gt;&#38;#39;, &#38;#39;, &#38;#39;, &#38;#39;&#38;#39;); ?&#38;gt; &#38;lt;/p&#38;gt;

					&#38;lt;/div&#38;gt;&#38;lt;!-- end content --&#38;gt;	

				&#38;lt;/div&#38;gt;&#38;lt;!-- end entry-content --&#38;gt;

			&#38;lt;/div&#38;gt;&#38;lt;!-- end entry --&#38;gt;

						&#38;lt;?php endforeach; ?&#38;gt;

			&#38;lt;?php include (TEMPLATEPATH . &#38;#39;/navigation.php&#38;#39;); ?&#38;gt;

		&#38;lt;?php else : ?&#38;gt;

			&#38;lt;h2 class=&#38;quot;page_header center&#38;quot;&#38;gt;Not Found&#38;lt;/h2&#38;gt;
			&#38;lt;div class=&#38;quot;entry&#38;quot;&#38;gt;
				&#38;lt;p class=&#38;quot;center&#38;quot;&#38;gt;Sorry, but you are looking for something that isn&#38;#39;t here.&#38;lt;/p&#38;gt;
				&#38;lt;?php include (TEMPLATEPATH . &#38;quot;/searchform.php&#38;quot;); ?&#38;gt;
			&#38;lt;/div&#38;gt;

		&#38;lt;?php endif; ?&#38;gt;

		&#38;lt;/div&#38;gt;&#38;lt;!-- end content-area--&#38;gt;

	&#38;lt;/div&#38;gt;&#38;lt;!-- end content-box --&#38;gt;

	&#38;lt;?php get_sidebar(); ?&#38;gt;

&#38;lt;?php get_footer(); ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>sambauers on "bb_query: get topics started within a date range?"</title>
<link>http://bbpress.org/forums/topic/bb_query-get-topics-started-within-a-date-range#post-16141</link>
<pubDate>Mon, 12 May 2008 02:23:44 +0000</pubDate>
<dc:creator>sambauers</dc:creator>
<guid isPermaLink="false">16141@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;&#60;a href=&#34;http://trac.bbpress.org/ticket/879&#34; rel=&#34;nofollow&#34;&#62;http://trac.bbpress.org/ticket/879&#60;/a&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>sambauers on "bb_query: get topics started within a date range?"</title>
<link>http://bbpress.org/forums/topic/bb_query-get-topics-started-within-a-date-range#post-16133</link>
<pubDate>Mon, 12 May 2008 01:20:19 +0000</pubDate>
<dc:creator>sambauers</dc:creator>
<guid isPermaLink="false">16133@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;BB_Query can't do this at the moment as far as I can tell. It probably should though.&#60;/p&#62;
&#60;p&#62;I'll make a trac ticket to suggest this.&#60;/p&#62;
&#60;p&#62;At the moment you could do two BB_Queries and intersect their results. But that's pretty poor.&#60;/p&#62;
&#60;p&#62;Just be sure if you do use a direct query that you prepare it first. e.g.:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$startdate=&#38;quot;20070602103049&#38;quot;;
$enddate=&#38;quot;20080212090232&#38;quot;;

$query = $bbdb-&#38;gt;prepare(&#38;quot;SELECT * FROM %s WHERE topic_start_time BETWEEN %s AND %s ORDER BY topic_start_time DESC&#38;quot;, $bbdb-&#38;gt;topics, $startdate, $enddate);
$topics = $bbdb-&#38;gt;get_results($query);&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>mrhoratio on "bb_query: get topics started within a date range?"</title>
<link>http://bbpress.org/forums/topic/bb_query-get-topics-started-within-a-date-range#post-15959</link>
<pubDate>Sun, 04 May 2008 05:00:30 +0000</pubDate>
<dc:creator>mrhoratio</dc:creator>
<guid isPermaLink="false">15959@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;I did some more digging, and it looks a way to do is to not use BB_query at all, but to use $bbdb-&#38;gt;get_results instead:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;/p&#62;
&#60;p&#62;$startdate=&#34;20070602103049&#34;;&#60;br /&#62;
$enddate=&#34;20080212090232&#34;;&#60;/p&#62;
&#60;p&#62;$topics = $bbdb-&#38;gt;get_results(&#34;SELECT * FROM $bbdb-&#38;gt;topics WHERE topic_start_time BETWEEN $startdate AND $enddate ORDER BY topic_start_time DESC&#34;);&#60;/p&#62;
&#60;p&#62;&#60;/code&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>mrhoratio on "bb_query: get topics started within a date range?"</title>
<link>http://bbpress.org/forums/topic/bb_query-get-topics-started-within-a-date-range#post-15954</link>
<pubDate>Sat, 03 May 2008 17:00:17 +0000</pubDate>
<dc:creator>mrhoratio</dc:creator>
<guid isPermaLink="false">15954@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;How do I use bb_query to fetch all topics that were started within a given date range?&#60;/p&#62;
&#60;p&#62;Here's an example found an example of a bb_query code on the bbPress blog:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;/p&#62;
&#60;p&#62;$topic_query = new BB_Query( 'topic',&#60;br /&#62;
	array(&#60;br /&#62;
		'topic_author' =&#38;gt; 'mdawaffe',&#60;br /&#62;
		'started' =&#38;gt; '2007-06',&#60;br /&#62;
		'tag' =&#38;gt; 'bbpress',&#60;br /&#62;
		'order_by' =&#38;gt; 'topic_start_time'&#60;br /&#62;
	)&#60;br /&#62;
);&#60;br /&#62;
$topic_query-&#38;gt;results; // Here's the array of topics the query returned.&#60;/p&#62;
&#60;p&#62;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;This shows how to get topics that where started on June 2007. But what if I wanted to get all topics that were started between June 2, 2007 10:30:49 PM and February 12, 2008 9:02:32 am?&#60;/p&#62;
&#60;p&#62;I think I may be missing something totally obvious. Any suggestions? I
&#60;/p&#62;</description>
</item>
<item>
<title>KJTED on "BB_Query class and next version of bbPress?"</title>
<link>http://bbpress.org/forums/topic/bb_query-class-and-next-version-of-bbpress#post-9363</link>
<pubDate>Thu, 26 Jul 2007 10:00:40 +0000</pubDate>
<dc:creator>KJTED</dc:creator>
<guid isPermaLink="false">9363@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;I've not forgotten about this. I will post up some code when i've finished. I've just written an insertion class too.
&#60;/p&#62;</description>
</item>
<item>
<title>KJTED on "BB_Query class and next version of bbPress?"</title>
<link>http://bbpress.org/forums/topic/bb_query-class-and-next-version-of-bbpress#post-9053</link>
<pubDate>Wed, 18 Jul 2007 09:15:13 +0000</pubDate>
<dc:creator>KJTED</dc:creator>
<guid isPermaLink="false">9053@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;Hi fel. I'll post up later today the process I went through. I'll get the latest version of the class right now! :) Thanks for the heads up.&#60;/p&#62;
&#60;p&#62;I've also done some work with CodeIgniter and Flash integration which I'll post a link to later in case anyone does CI development (off topic I know but still valuable).
&#60;/p&#62;</description>
</item>
<item>
<title>fel64 on "BB_Query class and next version of bbPress?"</title>
<link>http://bbpress.org/forums/topic/bb_query-class-and-next-version-of-bbpress#post-9038</link>
<pubDate>Tue, 17 Jul 2007 19:03:11 +0000</pubDate>
<dc:creator>fel64</dc:creator>
<guid isPermaLink="false">9038@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;It &#60;em&#62;is&#60;/em&#62; funkin' brilliant. I hope you downloaded the latest release ( &#60;a href=&#34;http://trac.bbpress.org/browser/trunk,&#34; rel=&#34;nofollow&#34;&#62;http://trac.bbpress.org/browser/trunk,&#60;/a&#62; at the bottom of the page is the Zip Archive link to the latest) because it has a bunch of fixes and changes.&#60;/p&#62;
&#60;p&#62;Can you detail anything you had to do to make it work, for future people who want to do this stuff? :)
&#60;/p&#62;</description>
</item>
<item>
<title>KJTED on "BB_Query class and next version of bbPress?"</title>
<link>http://bbpress.org/forums/topic/bb_query-class-and-next-version-of-bbpress#post-9033</link>
<pubDate>Tue, 17 Jul 2007 16:52:08 +0000</pubDate>
<dc:creator>KJTED</dc:creator>
<guid isPermaLink="false">9033@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;The BB_Query class is funkin' brilliant! I now have abstraction class to communicate between Flash and bbPress.
&#60;/p&#62;</description>
</item>
<item>
<title>KJTED on "BB_Query class and next version of bbPress?"</title>
<link>http://bbpress.org/forums/topic/bb_query-class-and-next-version-of-bbpress#post-9028</link>
<pubDate>Tue, 17 Jul 2007 14:55:48 +0000</pubDate>
<dc:creator>KJTED</dc:creator>
<guid isPermaLink="false">9028@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;I just noticed I can actually download it from the Roadmap in the development section...&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://trac.bbpress.org/ticket/657&#34; rel=&#34;nofollow&#34;&#62;http://trac.bbpress.org/ticket/657&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Without documentation I guess it'll be a case of figuring it out myself lol.&#60;/p&#62;
&#60;p&#62;Will the new version of bbPress have any structural changes to the database? I'm hoping I can use this class with the current version of bbPress.&#60;/p&#62;
&#60;p&#62;:)
&#60;/p&#62;</description>
</item>
<item>
<title>KJTED on "BB_Query class and next version of bbPress?"</title>
<link>http://bbpress.org/forums/topic/bb_query-class-and-next-version-of-bbpress#post-9027</link>
<pubDate>Tue, 17 Jul 2007 14:51:16 +0000</pubDate>
<dc:creator>KJTED</dc:creator>
<guid isPermaLink="false">9027@http://bbpress.org/forums/</guid>
<description>&#60;p&#62;I'm really anxious to get my hands on the BB_Query class because it looks like it'll help me a lot with my quest to integrate Vanilla into a Flash movie clip. Does anyone know when the next version of bbPress will be released as the blog states it will contain the new BB_Query class.&#60;/p&#62;
&#60;p&#62;Cheers&#60;br /&#62;
KJ
&#60;/p&#62;</description>
</item>

</channel>
</rss>
