Skip to content

Commit

Permalink
Make Controller_Tags::get_tag_query() quicker for single tag queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
shadlaws committed Jul 16, 2013
1 parent 67cea2b commit 0197194
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/tag/classes/Tag/Controller/Tags.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ public function action_find_by_name() {
* @see Controller_Tags::action_show() * @see Controller_Tags::action_show()
*/ */
static function get_tag_query($tags) { static function get_tag_query($tags) {
// For a single tag this would just be $tag->items->viewable(), but ORM doesn't handle if (count($tags) == 1) {
// multi-relationships as easily. So, we query the pivot table manually. We do a "where in..." return $tags[0]->items->viewable();
// which finds the items which have *any* of the tags, then require that the count be the total }
// number of tags to ensure the items have *all* of the tags.
// ORM doesn't handle multiple "has many through" relationships very easily,
// so we query the pivot table manually.
// @todo: try to do this in 1 query instead of 2 without tripping up count_all() and find_all(). // @todo: try to do this in 1 query instead of 2 without tripping up count_all() and find_all().


$tag_ids = array(); $tag_ids = array();
Expand Down

0 comments on commit 0197194

Please sign in to comment.