Skip to content

Instantly share code, notes, and snippets.

@sdepablos
Created May 7, 2010 10:04
Show Gist options
  • Select an option

  • Save sdepablos/393249 to your computer and use it in GitHub Desktop.

Select an option

Save sdepablos/393249 to your computer and use it in GitHub Desktop.
$intersections = false;
$filters = false;
// If any follows, followed_by, or tags are specified, attempt to narrow the search.
foreach ($this->follows as $cond)
{
$filters = true;
$keys = $this->database->set_members(Stalkr::get_type_table($this->type) . ':fing:' . $cond);
if (!$keys) continue;
$intersections = ($intersections === false) ? $keys : array_intersect($intersections, $keys);
}
foreach ($this->followed_by as $cond)
{
$filters = true;
$keys = $this->database->set_members(Stalkr::get_type_table($this->type) . ':fer:' . $cond);
if (!$keys) continue;
$intersections = ($intersections === false) ? $keys : array_intersect($intersections, $keys);
}
foreach ($this->tags as $tag)
{
$filters = true;
$tag = ctype_alnum($tag) ? $tag : base64_encode($tag);
$keys = $this->database->set_members(Stalkr::get_type_table($this->type) . ':tag:' . $tag);
if (!$keys) continue;
$intersections = ($intersections === false) ? $keys : array_intersect($intersections, $keys);
}
// Initialize the result set.
$this->result = array();
// Check for conditions and no results
if(($intersections === false) && ($filters === true)) {
return array();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment