Skip to content

Instantly share code, notes, and snippets.

@dmtrs
Created September 9, 2011 09:37
Show Gist options
  • Save dmtrs/1205840 to your computer and use it in GitHub Desktop.
Save dmtrs/1205840 to your computer and use it in GitHub Desktop.
<?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