Created
January 12, 2010 22:26
-
-
Save blaine/275693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = array(); | |
$select = "SELECT i.* , f.* "; | |
$from = "FROM $FOF_FEED_TABLE f, $FOF_ITEM_TABLE i, $FOF_SUBSCRIPTION_TABLE s "; | |
$where = sprintf("WHERE s.user_id = %d AND s.feed_id = f.feed_id AND f.feed_id = i.feed_id ", $user_id); | |
if(!is_null($feed) && $feed != "") | |
{ | |
$where .= sprintf("AND f.feed_id = %d ", $feed); | |
} | |
if(!is_null($when) && $when != "") | |
{ | |
$where .= sprintf("AND i.item_published > %d and i.item_published < %d ", $begin, $end); | |
} | |
if($what != "all") | |
{ | |
$tags = split(" ", $what); | |
$in = implode(", ", array_fill(0, count($tags), "'%s'")); | |
$from .= ", $FOF_TAG_TABLE t, $FOF_ITEM_TAG_TABLE it "; | |
$where .= sprintf("AND it.user_id = %d ", $user_id); | |
$where .= "AND it.tag_id = t.tag_id AND ( t.tag_name IN ( $in ) ) AND i.item_id = it.item_id "; | |
$group = sprintf("GROUP BY i.item_id HAVING COUNT( i.item_id ) = %d ", count($tags)); | |
$args = array_merge($args, $tags); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment