Created
June 9, 2011 07:37
-
-
Save michaeltwofish/1016261 to your computer and use it in GitHub Desktop.
Custom lithium finder
This file contains hidden or 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
<?php | |
// Create a finder for popular tags | |
static::finder('popular', function($self, $params, $chain) { | |
$params['options']['joins'] = array(new Query(array( | |
'source' => 'candidate_tags', | |
'constraint' => array ('Tag.id' => 'candidate_tags.tag_id'), | |
'group' => 'tag_id', | |
))); | |
$params['options']['fields'] = array('tag_id as id', 'name', 'client_id', 'count(tag_id) as theCount'); | |
$params['options']['order'] = 'theCount DESC'; | |
$params['options']['group'] = 'GROUP BY candidate_tags.tag_id'; | |
return $chain->next($self, $params, $chain); | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment