12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- class CategoryDao {
-
- public $id;
-
- public $name;
-
- public $dir;
-
- public $pid;
-
- public $grade;
-
- public $displayorder;
-
- public $questions;
-
- public $_table = t_category;
-
- public $_primarykey = "id";
-
- public $_fields = array ('id', 'name', 'dir', 'pid', 'grade', 'displayorder', 'questions' );
-
- /**
- * 获取擅长分类信息
- * @param unknown_type $cids
- */
- function get_expert_category_list($cids = "") {
- $sql = "select * from " . t_category . " where id in (" . $cids . ")";
-
- $query = Doo::db ()->query ( $sql );
-
- $result = $query->fetchAll ();
-
- return $result;
- }
-
- /**
- * 获取分类信息
- * @param unknown_type $data
- * @param unknown_type $condition
- * @param unknown_type $limit
- */
- function get_category_list($data = array(), $condition = "", $limit = "") {
-
- foreach ( $data as $key => $value ) {
- if (is_numeric ( $value ))
- $condition .= " and " . $key . " = " . $value;
- else
- $condition .= " and " . $key . " like '%" . $value . "%' ";
- }
-
- $condition = ' where 1 ' . $condition . $limit;
-
- $sql = "select * from " . t_category . $condition;
-
- $query = Doo::db ()->query ( $sql );
-
- $result = $query->fetchAll ();
-
- return $result;
- }
-
- /**
- * 批量删除分类和分类下的问题
- * @param unknown_type $id
- */
- function delete_category_list($id = array()) {
-
- $id = implode ( ",", $id );
-
- $sql = "delete from " . t_category . " where id in ( " . $id . " )";
-
- Doo::db ()->query ( $sql );
-
- $sql="delete ".t_question.",".t_answer." from ".t_question." left join ".t_answer." on (".t_question.".id=".t_answer.".qid) where ".t_question.".cid in (".$id.")";
- Doo::db ()->query ( $sql );
- }
-
- /**
- * 获取分类 根据ID
- * @param unknown_type $id
- */
- function get_category_by_id ( $id=0 ){
- $sql = "select * from " . t_category . " where id=".$id;
-
- $query = Doo::db ()->query ( $sql );
-
- $result = $query->fetch ();
-
- return $result;
- }
- }
- ?>
|