public function del() { if (!$GLOBALS['islogin']) { exit; } if (!checkpost()) { exit; } $ids = postvar('fids'); $str = orsql('id', $ids); $msg = M('msg'); $rs = $msg->field('SUM(new)')->where("uid={$GLOBALS['i']['uid']} AND ({$str})")->find(); $sum = $rs['SUM(new)']; $num = $GLOBALS['i']['new_msg'] - $sum; $member_field = M('member_field'); $edit['new_msg'] = $num < 0 ? 0 : $num; $member_field->where("uid={$GLOBALS['i']['uid']}")->save($edit); //echo $member_field->getLastSql(); //exit(); $data['status'] = 0; $data['new'] = 0; $msg->where("uid={$GLOBALS['i']['uid']} AND ({$str})")->save($data); //echo $msg->getLastSql(); //exit(); echo '200'; }
public function _assign_feed($face_size, $type = 'more', $page = 0, $is_last = 0, $last_id = 0) { $feed = M('feed'); $page = max(0, $page); $perpage = 10; $startnum = $perpage * $page; $where = ''; if ($type == 'index') { $where .= orsql('qh_feed.uid', trim($GLOBALS['i']['ifav_uids'], ',')); } $result = $feed->field('qh_feed.uid, qh_feed.body, qh_feed.count, qh_feed.type, qh_feed.body, qh_feed.add_time, qh_member.username, qh_member.default_pic, qh_member.sex')->join("LEFT JOIN qh_member ON qh_feed.uid=qh_member.uid")->where($where)->order('add_time DESC')->limit($startnum . ',' . $perpage)->select(); //echo $feed->getLastSql(); $feedlist = array(); foreach ($result as $row) { $feedlist[$row['uid']]['uid'] = $row['uid']; $feedlist[$row['uid']]['username'] = $row['username']; $feedlist[$row['uid']]['default_pic'] = $row['default_pic']; $feedlist[$row['uid']]['sex'] = $row['sex']; $feedlist[$row['uid']]['data'][] = $row; } $this->assign('face_size', $face_size); $this->assign('feedlist', $feedlist); $this->assign('is_last', $is_last); $this->assign('last_id', $last_id); }