<?php /** * 同事圈统计表 * User: 何岳龙 * Date: 2017年08月02日10:21:45 */ namespace Common\Model; class CountModel extends AbstractModel { // 话题被回复次数 const REPLIES_TOTAL = 1; // 话题被回复个数 const REPLIES_NUM = 2; // 回复话题次数 const REPLY_TOTAL = 3; // 回复话题个数 const REPLY_NUM = 4; // 发布话题次数 const CIRCLE_TOTAL = 5; /** * 构造方法 */ public function __construct() { parent::__construct(); } /** * 更新用户统计信息 * @param string $uid 话题用户UID * @param int $type 更新类型 * @return mixed */ public function update_by_total($uid = '', $type = self::REPLIES_TOTAL) { // 话题被回复 if ($type == self::REPLIES_TOTAL) { $sets[] = "replies_total=replies_total+1"; } // 回复话题次数 if ($type == self::REPLY_TOTAL) { $sets[] = "reply_total=reply_total+1"; } // 回复话题个数 if ($type == self::REPLY_NUM) { $sets[] = "reply_num=reply_num+1"; } // 发布话题 if ($type == self::CIRCLE_TOTAL) { $sets[] = "circle_total=circle_total+1"; } // 用户ID $wheres[] = "`uid`=?"; $params[] = $uid; // 企业标记 $wheres[] = "`domain`=?"; $params[] = QY_DOMAIN; // 状态条件 $wheres[] = "`status`<?"; $params[] = self::ST_DELETE; return $this->_m->execsql("UPDATE __TABLE__ SET " . implode(',', $sets) . " WHERE " . implode(' AND ', $wheres), $params); } }