query ( $sql ); } /** * 增加赞同数 * @param unknown_type $aid */ function update_support_answer($aid = 0) { $sql = "UPDATE `" . t_answer . "` SET `support` = `support` + 1 WHERE `id` = " . $aid; $query = Doo::db ()->query ( $sql ); } /** * 获取回答用户信息 * @param unknown_type $id */ function get_answer_user_info_by_id($id = 0) { $sql = "select * from " . t_answer . " as a left join " . t_user . " as b on (a.authorid=b.uid) left join " . t_usergroup . " as c on (b.groupid=c.groupid) where a.qid=" . $id; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); return $result; } /** * 添加一个追问 * @param unknown_type $data */ public function update_taginfo_by_id($data = array()) { $sql = "UPDATE `" . t_answer . "` SET `tag` = '" . $data ['tag'] . "' ,tagtime='".$data ['tagtime']."' WHERE `id` = " . $data ['id']; $query = Doo::db ()->query ( $sql ); } /** * 获取回答信息 * @param unknown_type $data */ public function get_answer_by_id($id = 0) { $sql = "select * from " . t_answer . " where id=" . $id . " limit 1"; $query = Doo::db ()->query ( $sql ); $result = $query->fetch (); return $result; } /** * 获取回答信息 * @param unknown_type $data */ public function get_answer_by_qid($qid = 0) { $sql = "select * from " . t_answer . " where qid=" . $qid ; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); return $result; } /** * 获取用户回答的记录数 * @param unknown_type $uid */ public function get_answer_count_by_uid($uid = 0) { $sql = "select count(*) as count from " . t_answer . " where authorid = " . $uid; $query = Doo::db ()->query ( $sql ); $result = $query->fetch (); return $result; } /** * 获取用户回答信息 * @param unknown_type $uid * @param unknown_type $limit */ public function get_answer_list($uid = 0, $limit = array()) { $limit = " order by a.time desc limit " . $limit ['lower'] . ", " . $limit ['size'] . ""; $sql = "select * from " . t_answer . " as a left join " . t_question . " as b on (b.id=a.qid and b.hidden=0) where a.authorid = " . $uid . $limit; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); return $result; } /** * 更新一条回答信息 * @param unknown_type $data * @param unknown_type $condition */ function update_answer($data = array(), $condition = "") { $prams = array (); foreach ( $data as $key => $value ) { $src = $key . " = '" . $value . "' "; array_push ( $prams, $src ); } $prams = implode ( ",", $prams ); $sql = "UPDATE `" . t_answer . "` SET " . $prams . " " . $condition; $query = Doo::db ()->query ( $sql ); } /** * 根据回答ID,问题ID * @param unknown_type $aid * @param unknown_type $qid */ function get_answer_by_aqid ( $aid, $qid ){ $sql = "select * from " . t_answer . " where id=" . $aid . " and qid=" . $qid; $query = Doo::db ()->query ( $sql ); $result = $query->fetch (); return $result; } /** * 根据回答ID,问题ID * @param unknown_type $aid * @param unknown_type $qid */ function get_answer_by_quid ( $qid, $uid ){ $sql = "select * from " . t_answer . " where qid=" . $qid . " and authorid=" . $uid; $query = Doo::db ()->query ( $sql ); $result = $query->fetch (); return $result; } /** * 批量删除回答 * @param unknown_type $id */ function delete_answer_list($id = array()) { $id = implode ( ",", $id ); $sql = "delete from " . $this->_table . " where id in ( " . $id . " )"; Doo::db ()->query ( $sql ); } } ?>