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; } } ?>