本文整理汇总了PHP中Fave::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Fave::count方法的具体用法?PHP Fave::count怎么用?PHP Fave::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fave
的用法示例。
在下文中一共展示了Fave::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countExistingFaves
/**
* Count the number of faves a notice already has. Used to initalize
* a tally for a notice.
*
* @param integer $noticeID ID of the notice to count faves for
*
* @return integer $total total number of time the notice has been favored
*/
static function countExistingFaves($noticeID)
{
$fave = new Fave();
$fave->notice_id = $noticeID;
$total = $fave->count();
return $total;
}
示例2: faveCount
function faveCount()
{
$c = Cache::instance();
if (!empty($c)) {
$cnt = $c->get(Cache::key('profile:fave_count:' . $this->id));
if (is_integer($cnt)) {
return (int) $cnt;
}
}
$faves = new Fave();
$faves->user_id = $this->id;
$cnt = (int) $faves->count('notice_id');
if (!empty($c)) {
$c->set(Cache::key('profile:fave_count:' . $this->id), $cnt);
}
return $cnt;
}
示例3: faveCount
function faveCount()
{
$c = common_memcache();
if (!empty($c)) {
$cnt = $c->get(common_cache_key('profile:fave_count:' . $this->id));
if (is_integer($cnt)) {
return (int) $cnt;
}
}
$faves = new Fave();
$faves->user_id = $this->id;
$cnt = (int) $faves->count('distinct notice_id');
if (!empty($c)) {
$c->set(common_cache_key('profile:fave_count:' . $this->id), $cnt);
}
return $cnt;
}
示例4: countByProfile
static function countByProfile(Profile $profile)
{
$c = Cache::instance();
if (!empty($c)) {
$cnt = $c->get(Cache::key('fave:count_by_profile:' . $profile->id));
if (is_integer($cnt)) {
return $cnt;
}
}
$faves = new Fave();
$faves->user_id = $profile->id;
$cnt = (int) $faves->count('notice_id');
if (!empty($c)) {
$c->set(Cache::key('fave:count_by_profile:' . $profile->id), $cnt);
}
return $cnt;
}