本文整理汇总了PHP中kshowPeer::doSelectJoinKuser方法的典型用法代码示例。如果您正苦于以下问题:PHP kshowPeer::doSelectJoinKuser方法的具体用法?PHP kshowPeer::doSelectJoinKuser怎么用?PHP kshowPeer::doSelectJoinKuser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kshowPeer
的用法示例。
在下文中一共展示了kshowPeer::doSelectJoinKuser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelatedShows
/**
* Will return an array of kshows that are 'related' to a given show
*
* @param string $kshow_id
* @return array of
*/
public static function getRelatedShows($kshow_id, $kuser_id, $amount)
{
$c = new Criteria();
$c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
$c->add(kshowPeer::ID, 10000, Criteria::GREATER_EQUAL);
//$c->add( kshowPeer::PRODUCER_ID, $kuser_id );
// our related algorithm is based on finding shows that have similar 'heavy' tags
if ($kshow_id) {
$kshow = kshowPeer::retrieveByPK($kshow_id);
if ($kshow) {
$tags_string = $kshow->getTags();
if ($tags_string) {
$tagsweight = array();
foreach (ktagword::getTagsArray($tags_string) as $tag) {
$tagsweight[$tag] = ktagword::getWeight($tag);
}
arsort($tagsweight);
$counter = 0;
foreach ($tagsweight as $tag => $weight) {
if ($counter++ > 2) {
break;
} else {
//we'll be looking for shows that have similar top tags (3 in this case)
$c->addOr(kshowPeer::TAGS, '%' . $tag . '%', Criteria::LIKE);
}
}
}
// and of course, we don't want the show itself
$c->addAnd(kshowPeer::ID, $kshow_id, Criteria::NOT_IN);
}
}
// we want recent ones
$c->addDescendingOrderByColumn(kshowPeer::UPDATED_AT);
$c->setLimit($amount);
$shows = kshowPeer::doSelectJoinKuser($c);
//did we get enough?
$amount_related = count($shows);
if ($amount_related < $amount) {
// let's get some more, which are not really related, but recent
$c = new Criteria();
$c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
$c->addDescendingOrderByColumn(kshowPeer::UPDATED_AT);
$c->setLimit($amount - $amount_related);
$moreshows = kshowPeer::doSelectJoinKuser($c);
return array_merge($shows, $moreshows);
}
return $shows;
}