123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?php
- class AnswerDao {
-
- public $id;
-
- public $qid;
-
- public $title;
-
- public $author;
-
- public $authorid;
-
- public $time;
-
- public $adopttime;
-
- public $content;
-
- public $comment;
-
- public $status;
-
- public $ip;
-
- public $tag;
-
- public $support;
-
- public $against;
-
- public $_table = 'zhask_answer';
-
- public $_primarykey = "id";
-
- public $_fields = array ('id', 'qid', 'title', 'author', 'authorid', 'time', 'adopttime', 'content', 'comment', 'status', 'ip', 'tag', 'support', 'against' );
-
- /**
- * 删除某个用户的所以回答
- * @param unknown_type $uid
- */
- function delete_answer_by_authorid($uid = 0) {
-
- $sql = "delete from " . t_answer . " where authorid = " . $uid;
-
- Doo::db ()->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 );
- }
- }
- ?>
|