本文整理汇总了PHP中Reply::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Reply::fetch方法的具体用法?PHP Reply::fetch怎么用?PHP Reply::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reply
的用法示例。
在下文中一共展示了Reply::fetch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Reply
function _streamDirect($user_id, $offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0)
{
$reply = new Reply();
$reply->profile_id = $user_id;
if ($since_id != 0) {
$reply->whereAdd('notice_id > ' . $since_id);
}
if ($max_id != 0) {
$reply->whereAdd('notice_id <= ' . $max_id);
}
$reply->orderBy('notice_id DESC');
if (!is_null($offset)) {
$reply->limit($offset, $limit);
}
$ids = array();
if ($reply->find()) {
while ($reply->fetch()) {
$ids[] = $reply->notice_id;
}
}
return $ids;
}
示例2: clearReplies
function clearReplies()
{
$replyNotice = new Notice();
$replyNotice->reply_to = $this->id;
//Null any notices that are replies to this notice
if ($replyNotice->find()) {
while ($replyNotice->fetch()) {
$orig = clone $replyNotice;
$replyNotice->reply_to = null;
$replyNotice->update($orig);
}
}
// Reply records
$reply = new Reply();
$reply->notice_id = $this->id;
if ($reply->find()) {
while ($reply->fetch()) {
self::blow('reply:stream:%d', $reply->profile_id);
$reply->delete();
}
}
$reply->free();
}
示例3: onHandleQueuedNotice
public function onHandleQueuedNotice(Notice $notice)
{
$paths = array();
// Add to the author's timeline
try {
$profile = $notice->getProfile();
} catch (Exception $e) {
$this->log(LOG_ERR, $e->getMessage());
return true;
}
try {
$user = $profile->getUser();
$paths[] = array('showstream', $user->nickname, null);
} catch (NoSuchUserException $e) {
// We really should handle the remote profile views too
$user = null;
}
// Add to the public timeline
$is_local = intval($notice->is_local);
if ($is_local === Notice::LOCAL_PUBLIC || $is_local === Notice::REMOTE && !common_config('public', 'localonly')) {
$paths[] = array('public', null, null);
}
// Add to the tags timeline
$tags = $this->getNoticeTags($notice);
if (!empty($tags)) {
foreach ($tags as $tag) {
$paths[] = array('tag', $tag, null);
}
}
// Add to inbox timelines
// XXX: do a join
$ni = $notice->whoGets();
foreach (array_keys($ni) as $user_id) {
$user = User::getKV('id', $user_id);
$paths[] = array('all', $user->nickname, null);
}
// Add to the replies timeline
$reply = new Reply();
$reply->notice_id = $notice->id;
if ($reply->find()) {
while ($reply->fetch()) {
$user = User::getKV('id', $reply->profile_id);
if (!empty($user)) {
$paths[] = array('replies', $user->nickname, null);
}
}
}
// Add to the group timeline
// XXX: join
$gi = new Group_inbox();
$gi->notice_id = $notice->id;
if ($gi->find()) {
while ($gi->fetch()) {
$ug = User_group::getKV('id', $gi->group_id);
$paths[] = array('showgroup', $ug->nickname, null);
}
}
if (count($paths) > 0) {
$json = $this->noticeAsJson($notice);
$this->_connect();
// XXX: We should probably fan-out here and do a
// new queue item for each path
foreach ($paths as $path) {
list($action, $arg1, $arg2) = $path;
$channels = Realtime_channel::getAllChannels($action, $arg1, $arg2);
$this->log(LOG_INFO, sprintf(_("%d candidate channels for notice %d"), count($channels), $notice->id));
foreach ($channels as $channel) {
// XXX: We should probably fan-out here and do a
// new queue item for each user/path combo
if (is_null($channel->user_id)) {
$profile = null;
} else {
$profile = Profile::getKV('id', $channel->user_id);
}
if ($notice->inScope($profile)) {
$this->log(LOG_INFO, sprintf(_("Delivering notice %d to channel (%s, %s, %s) for user '%s'"), $notice->id, $channel->action, $channel->arg1, $channel->arg2, $profile ? $profile->nickname : "<public>"));
$timeline = $this->_pathToChannel(array($channel->channel_key));
$this->_publish($timeline, $json);
}
}
}
$this->_disconnect();
}
return true;
}
示例4: onHandleQueuedNotice
function onHandleQueuedNotice($notice)
{
$paths = array();
// Add to the author's timeline
$user = User::staticGet('id', $notice->profile_id);
if (!empty($user)) {
$paths[] = array('showstream', $user->nickname);
}
// Add to the public timeline
if ($notice->is_local == Notice::LOCAL_PUBLIC || $notice->is_local == Notice::REMOTE_OMB && !common_config('public', 'localonly')) {
$paths[] = array('public');
}
// Add to the tags timeline
$tags = $this->getNoticeTags($notice);
if (!empty($tags)) {
foreach ($tags as $tag) {
$paths[] = array('tag', $tag);
}
}
// Add to inbox timelines
// XXX: do a join
$ni = $notice->whoGets();
foreach (array_keys($ni) as $user_id) {
$user = User::staticGet('id', $user_id);
$paths[] = array('all', $user->nickname);
}
// Add to the replies timeline
$reply = new Reply();
$reply->notice_id = $notice->id;
if ($reply->find()) {
while ($reply->fetch()) {
$user = User::staticGet('id', $reply->profile_id);
if (!empty($user)) {
$paths[] = array('replies', $user->nickname);
}
}
}
// Add to the group timeline
// XXX: join
$gi = new Group_inbox();
$gi->notice_id = $notice->id;
if ($gi->find()) {
while ($gi->fetch()) {
$ug = User_group::staticGet('id', $gi->group_id);
$paths[] = array('showgroup', $ug->nickname);
}
}
if (count($paths) > 0) {
$json = $this->noticeAsJson($notice);
$this->_connect();
foreach ($paths as $path) {
$timeline = $this->_pathToChannel($path);
$this->_publish($timeline, $json);
}
$this->_disconnect();
}
return true;
}
示例5: blowRepliesCache
function blowRepliesCache($blowLast = false)
{
$cache = common_memcache();
if ($cache) {
$reply = new Reply();
$reply->notice_id = $this->id;
if ($reply->find()) {
while ($reply->fetch()) {
$cache->delete(common_cache_key('user:replies:' . $reply->profile_id));
if ($blowLast) {
$cache->delete(common_cache_key('user:replies:' . $reply->profile_id . ';last'));
}
}
}
$reply->free();
unset($reply);
}
}