table)->one($where); if ($info) { return true; } else { return false; } } # 获取当前用户的数据列表 public function getList($uid) { $where['uid'] = $uid; $info = Dever::db($this->table)->getAll($where); return $info; } # 获取当前的点赞名单 public function getData($id, $type, $collection_id) { $where['type'] = $type; $where['type_id'] = $id; $info = Dever::db($this->table)->getHot($where); $result = array(); $result['user'] = array(); $result['total'] = 0; if ($info) { foreach ($info as $k => $v) { $user = Dever::load('user/lib/info')->get($v['uid'], $collection_id, true); $result['user']['user_' . $v['uid']] = array ( 'id' => $v['uid'], 'username' => $user['username'], 'author' => $user['author'], 'username_text' => $user['username_text'], ); } } $max = 1; $total = count($info); if ($total >= $max) { $all = Dever::db($this->table)->getTotal($where); if ($all > $total) { $result['total'] = $all - $total; } } return $result; } # 更新提交数据 public function submit($info_id, $uid, $id, $type, $data = array()) { if ($this->otable) { $oinfo = Dever::load($this->otable)->get($uid, $id, $type); if ($oinfo) { Dever::alert('已经做过其他操作'); } } $where['uid'] = $uid; $where['type_id'] = $id; $where['type'] = $type; $info = Dever::db($this->table)->one($where); if ($data) { $where += $data; } if (!$info) { $up = 1; Dever::db($this->table)->insert($where); } else { $up = 2; Dever::db($this->table)->delete($info['id']); } # 更新点赞数 $where = array(); $where['type_id'] = $id; $where['type'] = $type; $where['state'] = 1; $total = Dever::db($this->table)->total($where); $table = Dever::config('base')->table_name[$type]; $state = Dever::db($table)->update(array('where_id' => $id, 'num_' . $this->name => $total)); if ($up == 1) { Dever::score($uid, 'submit_' . $this->name, $this->lang, false, false, false, 'collection/info', $info_id); } else { Dever::score($uid, 'submit_no_' . $this->name, '取消' . $this->lang, false, false, false, 'collection/info', $info_id); } return true; } }