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


PHP post::preload_num_new_comments方法代码示例

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


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

示例1: while

 $buff = NULL;
 while ($obj = $db2->fetch_object($res)) {
     $buff = new post($obj->type, FALSE, $obj);
     if ($buff->error) {
         continue;
     }
     $tmpposts[] = $buff;
     if ($this->param('from') == 'ajax' && $this->param('onlypost') != "" && $this->param('onlypost') != $buff->post_tmp_id) {
         continue;
     }
     $tmpids[] = $buff->post_tmp_id;
     $postusrs[] = $buff->post_user->id;
 }
 unset($buff);
 $postusrs = array_unique($postusrs);
 post::preload_num_new_comments($tmpids);
 ob_start();
 $D->if_follow_me = array();
 if (count($postusrs) > 0) {
     $r = $db2->query('SELECT who FROM users_followed WHERE who IN (' . implode(',', $postusrs) . ') AND whom="' . $this->user->id . '"');
     while ($o = $db2->fetch_object($r)) {
         if (isset($D->if_follow_me[$o->who])) {
             continue;
         }
         $D->if_follow_me[$o->who] = 1;
     }
 }
 $D->i_follow = array_fill_keys(array_keys($this->network->get_user_follows($this->user->id, FALSE, 'hefollows')->follow_users), 1);
 $D->i_follow[] = $this->user->id;
 foreach ($tmpposts as $tmp) {
     $D->p = $tmp;
开发者ID:chaobj001,项目名称:tt,代码行数:31,代码来源:dashboard.php

示例2: preload_num_new_comments

 public static function preload_num_new_comments($tmpid)
 {
     global $user, $db2;
     if (!$user->is_logged) {
         return 0;
     }
     static $loaded = array();
     if (!is_array($tmpid)) {
         if (isset($loaded[$tmpid])) {
             return $loaded[$tmpid];
         }
         list($tp, $pid) = explode('_', $tmpid);
         $newcomments = $db2->fetch_field('SELECT newcomments FROM ' . ($tp == 'private' ? 'posts_pr_comments_watch' : 'posts_comments_watch') . ' WHERE user_id="' . $user->id . '" AND post_id="' . $pid . '" LIMIT 1');
         $loaded[$tmpid] = $newcomments ? intval($newcomments) : 0;
         return $loaded[$tmpid];
     }
     $return = 0;
     $publ = array();
     $priv = array();
     foreach ($tmpid as $i => $tid) {
         if (isset($loaded[$tid])) {
             $return += $loaded[$tid];
             unset($tmpid[$i]);
             continue;
         }
         list($tp, $pid) = explode('_', $tid);
         $tp == 'private' ? $priv[] = $pid : ($publ[] = $pid);
     }
     if (count($publ) == 1) {
         $return += post::preload_num_new_comments('public_' . reset($publ));
     }
     if (count($priv) == 1) {
         $return += post::preload_num_new_comments('private_' . reset($priv));
     }
     $tmp = array();
     if (count($publ) > 1) {
         $r = $db2->query('SELECT post_id, newcomments FROM posts_comments_watch WHERE user_id="' . $user->id . '" AND post_id IN(' . implode(', ', $publ) . ') LIMIT ' . count($publ), FALSE);
         while ($obj = $db2->fetch_object($r)) {
             $tmp['public_' . $obj->post_id] = intval($obj->newcomments);
         }
     }
     if (count($priv) > 1) {
         $r = $db2->query('SELECT post_id, newcomments FROM posts_pr_comments_watch WHERE user_id="' . $user->id . '" AND post_id IN(' . implode(', ', $priv) . ') LIMIT ' . count($priv), FALSE);
         while ($obj = $db2->fetch_object($r)) {
             $tmp['private_' . $obj->post_id] = intval($obj->newcomments);
         }
     }
     foreach ($tmpid as $tid) {
         $loaded[$tid] = isset($tmp[$tid]) ? $tmp[$tid] : 0;
     }
     foreach ($tmp as $n) {
         $return += $n;
     }
     return $return;
 }
开发者ID:chaobj001,项目名称:tt,代码行数:55,代码来源:class_post.php


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