本文整理汇总了PHP中Fave::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Fave::limit方法的具体用法?PHP Fave::limit怎么用?PHP Fave::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fave
的用法示例。
在下文中一共展示了Fave::limit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$weightexpr = common_sql_weight('modified', common_config('popular', 'dropoff'));
$cutoff = sprintf("modified > '%s'", common_sql_date(time() - common_config('popular', 'cutoff')));
$fave = new Fave();
$fave->selectAdd();
$fave->selectAdd('notice_id');
$fave->selectAdd("{$weightexpr} as weight");
$fave->whereAdd($cutoff);
$fave->orderBy('weight DESC');
$fave->groupBy('notice_id');
if (!is_null($offset)) {
$fave->limit($offset, $limit);
}
// FIXME: $since_id, $max_id are ignored
$ids = array();
if ($fave->find()) {
while ($fave->fetch()) {
$ids[] = $fave->notice_id;
}
}
return $ids;
}
示例2: byProfile
/**
* Fetch a stream of favorites by profile
*
* @param integer $profileId Profile that faved
* @param integer $offset Offset from last
* @param integer $limit Number to get
*
* @return mixed stream of faves, use fetch() to iterate
*
* @todo Cache results
* @todo integrate with Fave::stream()
*/
static function byProfile($profileId, $offset, $limit)
{
$fav = new Fave();
$fav->user_id = $profileId;
$fav->orderBy('modified DESC');
$fav->limit($offset, $limit);
$fav->find();
return $fav;
}
示例3: handle
/**
* Handle the request
*
* Check the format and show the user info
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
// favs
$fave = new Fave();
$fave->selectAdd();
$fave->selectAdd('user_id');
$fave->selectAdd('modified');
$fave->notice_id = $this->original->id;
$fave->orderBy('modified');
if (!is_null($this->cnt)) {
$fave->limit(0, $this->cnt);
}
$fav_ids = $fave->fetchAll('user_id', 'modified');
// get nickname and profile image
$fav_ids_with_profile_data = array();
$i = 0;
foreach ($fav_ids as $id => $time) {
$profile = Profile::getKV('id', $id);
$fav_ids_with_profile_data[$i]['user_id'] = $id;
$fav_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
$fav_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
$fav_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
$fav_ids_with_profile_data[$i]['time'] = strtotime($time);
$profile = new Profile();
$profile->id = $id;
$avatarurl = $profile->avatarUrl(48);
$fav_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
$i++;
}
// repeats
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('profile_id');
$notice->selectAdd('created');
$notice->repeat_of = $this->original->id;
$notice->orderBy('created, id');
// NB: asc!
if (!is_null($this->cnt)) {
$notice->limit(0, $this->cnt);
}
$repeat_ids = $notice->fetchAll('profile_id', 'created');
// get nickname and profile image
$repeat_ids_with_profile_data = array();
$i = 0;
foreach ($repeat_ids as $id => $time) {
$profile = Profile::getKV('id', $id);
$repeat_ids_with_profile_data[$i]['user_id'] = $id;
$repeat_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
$repeat_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
$repeat_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
$repeat_ids_with_profile_data[$i]['time'] = strtotime($time);
$profile = new Profile();
$profile->id = $id;
$avatarurl = $profile->avatarUrl(48);
$repeat_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
$i++;
}
$favs_and_repeats = array('favs' => $fav_ids_with_profile_data, 'repeats' => $repeat_ids_with_profile_data);
$this->initDocument('json');
$this->showJsonObjects($favs_and_repeats);
$this->endDocument('json');
}
示例4: handle
/**
* Handle the request
*
* Check the format and show the user info
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
// since this api method is in practice only used when expanding a
// notice, we can assume the user has seen the notice in question,
// an no longer need a notification about it. mark reply/mention-
// notifications tied to this notice and the current profile as read
if ($this->auth_user) {
QvitterPlugin::markNotificationAsSeen($this->notice_id, $this->auth_user->id, 'mention');
QvitterPlugin::markNotificationAsSeen($this->notice_id, $this->auth_user->id, 'reply');
}
// favs
$fave = new Fave();
$fave->selectAdd();
$fave->selectAdd('user_id');
$fave->selectAdd('modified');
$fave->notice_id = $this->original->id;
$fave->orderBy('modified');
if (!is_null($this->cnt)) {
$fave->limit(0, $this->cnt);
}
$fav_ids = $fave->fetchAll('user_id', 'modified');
// get nickname and profile image
$fav_ids_with_profile_data = array();
$i = 0;
foreach ($fav_ids as $id => $time) {
$profile = Profile::getKV('id', $id);
$fav_ids_with_profile_data[$i]['user_id'] = $id;
$fav_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
$fav_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
$fav_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
$fav_ids_with_profile_data[$i]['time'] = strtotime($time);
$profile = new Profile();
$profile->id = $id;
$avatarurl = $profile->avatarUrl(48);
$fav_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
$i++;
}
// repeats
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('profile_id');
$notice->selectAdd('created');
$notice->repeat_of = $this->original->id;
$notice->verb = ActivityVerb::SHARE;
$notice->orderBy('created, id');
// NB: asc!
if (!is_null($this->cnt)) {
$notice->limit(0, $this->cnt);
}
$repeat_ids = $notice->fetchAll('profile_id', 'created');
// get nickname and profile image
$repeat_ids_with_profile_data = array();
$i = 0;
foreach ($repeat_ids as $id => $time) {
$profile = Profile::getKV('id', $id);
$repeat_ids_with_profile_data[$i]['user_id'] = $id;
$repeat_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
$repeat_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
$repeat_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
$repeat_ids_with_profile_data[$i]['time'] = strtotime($time);
$profile = new Profile();
$profile->id = $id;
$avatarurl = $profile->avatarUrl(48);
$repeat_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
$i++;
}
$favs_and_repeats = array('favs' => $fav_ids_with_profile_data, 'repeats' => $repeat_ids_with_profile_data);
$this->initDocument('json');
$this->showJsonObjects($favs_and_repeats);
$this->endDocument('json');
}
示例5: handle
/**
* Handle the request
*
* Get favs and return them as json object
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
$fave = new Fave();
$fave->selectAdd();
$fave->selectAdd('user_id');
$fave->notice_id = $this->original->id;
$fave->orderBy('modified');
if (!is_null($this->cnt)) {
$fave->limit(0, $this->cnt);
}
$ids = $fave->fetchAll('user_id');
// get nickname and profile image
$ids_with_profile_data = array();
$i = 0;
foreach ($ids as $id) {
$profile = Profile::getKV('id', $id);
$ids_with_profile_data[$i]['user_id'] = $id;
$ids_with_profile_data[$i]['nickname'] = $profile->nickname;
$ids_with_profile_data[$i]['fullname'] = $profile->fullname;
$ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
$profile = new Profile();
$profile->id = $id;
$avatarurl = $profile->avatarUrl(24);
$ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
$i++;
}
$this->initDocument('json');
$this->showJsonObjects($ids_with_profile_data);
$this->endDocument('json');
}