当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscription::limit方法代码示例

本文整理汇总了PHP中Subscription::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::limit方法的具体用法?PHP Subscription::limit怎么用?PHP Subscription::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::limit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getNthSub

 /**
  * Get the Nth most recent subscription for this user
  *
  * @param User    $user The user to get subscriptions for
  * @param integer $n    How far to count back
  *
  * @return Subscription a subscription or null
  */
 private function _getNthSub($user, $n)
 {
     $sub = new Subscription();
     $sub->subscriber = $user->id;
     $sub->orderBy('created DESC');
     $sub->limit($n - 1, 1);
     if ($sub->find(true)) {
         return $sub;
     } else {
         return null;
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:20,代码来源:SubscriptionThrottlePlugin.php

示例2: getSubscriptionIDs

 private static function getSubscriptionIDs($get_type, $profile_id, $offset, $limit)
 {
     switch ($get_type) {
         case 'subscribed':
             $by_type = 'subscriber';
             break;
         case 'subscriber':
             $by_type = 'subscribed';
             break;
         default:
             throw new Exception('Bad type argument to getSubscriptionIDs');
     }
     $cacheKey = 'subscription:by-' . $by_type . ':' . $profile_id;
     $queryoffset = $offset;
     $querylimit = $limit;
     if ($offset + $limit <= self::CACHE_WINDOW) {
         // Oh, it seems it should be cached
         $ids = self::cacheGet($cacheKey);
         if (is_array($ids)) {
             return array_slice($ids, $offset, $limit);
         }
         // Being here indicates we didn't find anything cached
         // so we'll have to fill it up simultaneously
         $queryoffset = 0;
         $querylimit = self::CACHE_WINDOW;
     }
     $sub = new Subscription();
     $sub->{$by_type} = $profile_id;
     $sub->selectAdd($get_type);
     $sub->whereAdd("{$get_type} != {$profile_id}");
     $sub->orderBy('created DESC');
     $sub->limit($queryoffset, $querylimit);
     if (!$sub->find()) {
         return array();
     }
     $ids = $sub->fetchAll($get_type);
     // If we're simultaneously filling up cache, remember to slice
     if ($queryoffset === 0 && $querylimit === self::CACHE_WINDOW) {
         self::cacheSet($cacheKey, $ids);
         return array_slice($ids, $offset, $limit);
     }
     return $ids;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:43,代码来源:Subscription.php

示例3: realBySubscribed

 private static function realBySubscribed($subscribedId, $offset, $limit)
 {
     $sub = new Subscription();
     $sub->subscribed = $subscribedId;
     $sub->whereAdd('subscriber != ' . $subscribedId);
     $sub->orderBy('created DESC');
     $sub->limit($offset, $limit);
     $sub->find();
     $subs = array();
     while ($sub->fetch()) {
         $subs[] = clone $sub;
     }
     return $subs;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:14,代码来源:Subscription.php

示例4: subscriptions

 function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs = false)
 {
     $this->auth_user = $apidata['user'];
     $user = $this->get_user($apidata['api_arg'], $apidata);
     if (!$user) {
         $this->clientError('Not Found', 404, $apidata['content-type']);
         return;
     }
     $page = $this->trimmed('page');
     if (!$page || !is_numeric($page)) {
         $page = 1;
     }
     $profile = $user->getProfile();
     if (!$profile) {
         $this->serverError(_('User has no profile.'));
         return;
     }
     $sub = new Subscription();
     $sub->{$user_attr} = $profile->id;
     $since = strtotime($this->trimmed('since'));
     if ($since) {
         $d = date('Y-m-d H:i:s', $since);
         $sub->whereAdd("created > '{$d}'");
     }
     $sub->orderBy('created DESC');
     if (!$onlyIDs) {
         $sub->limit(($page - 1) * 100, 100);
     }
     $others = array();
     if ($sub->find()) {
         while ($sub->fetch()) {
             $others[] = Profile::staticGet($sub->{$other_attr});
         }
     } else {
         // user has no followers
     }
     $type = $apidata['content-type'];
     $this->init_document($type);
     if ($onlyIDs) {
         $this->showIDs($others, $type);
     } else {
         $this->show_profiles($others, $type);
     }
     $this->end_document($type);
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:45,代码来源:twitapistatuses.php


注:本文中的Subscription::limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。