Created
September 9, 2011 09:37
-
-
Save dmtrs/1205840 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
<?php | |
public function searchStarredMembers( $tag=null, $keyword=null, $myStar = true) | |
{ | |
$with = array('myMemberStar'); | |
if(isset($tag)) { | |
if($tag) { | |
$with = array( | |
'myMemberStar'=>array( | |
'with'=> array( | |
'starToTags'=>array( | |
'joinType'=>'INNER JOIN', | |
'condition'=>'starToTags.member_star_tag_id =:tagId', | |
'params'=>array(':tagId'=>$tag), | |
'together'=>true, | |
) | |
) | |
) | |
); | |
} else { | |
$with = array( | |
'myMemberStar'=>array( | |
'with'=>array( | |
'starToTags'=>array( | |
'condition'=>'starToTags.member_star_tag_id IS NULL', | |
'together'=>true, | |
) | |
) | |
) | |
); | |
} | |
$member = Members::model()->with(array( | |
'stars'=>array( | |
'together'=>true, | |
'with'=>$with | |
) | |
))->find(); | |
$stars = (isset($member)) ? $member->stars : array(); | |
} else { | |
$stars = $this->stars; | |
} | |
return new CArrayDataProvider($stars, array('keyField'=>'mem_id')); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment