Article.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class Article extends DooModel {
  4. public $aid;
  5. public $title;
  6. public $content;
  7. public $synopsis;
  8. public $thum;
  9. public $a_type;
  10. public $trainingType;
  11. public $area;
  12. public $enroll;
  13. public $enroll_title;
  14. public $enroll_obj;
  15. public $enroll_content;
  16. public $enroll_fun;
  17. public $enroll_adrr;
  18. public $enroll_pay;
  19. public $enroll_name;
  20. public $enroll_downdoc;
  21. public $enroll_mark;
  22. public $attachment;
  23. public $cid;
  24. public $enroll_time;
  25. public $time;
  26. public $update_time;
  27. public $_table = 'sc_article';
  28. public $_primarykey = 'aid';
  29. public $_fields = array ('aid', 'title', 'content','synopsis','thum' ,'a_type','trainingType','area','enroll_title', 'enroll','enroll_obj','enroll_content',
  30. 'enroll_fun','enroll_adrr','enroll_pay','enroll_name','enroll_downdoc','enroll_mark','attachment', 'cid','enroll_time', 'time','update_time' );
  31. function getArticleById($aid = 0) {
  32. return $this->find ( array ('desc' => 'time', 'where' => 'aid=' . $aid, 'asArray' => TRUE ) );
  33. }
  34. function getArticleByTrain($trainingType=2){
  35. return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2 and trainingType='.$trainingType, 'asArray' => TRUE ) );
  36. }
  37. function getArticleByTrainAid($aid){
  38. return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2 and aid='.$aid, 'asArray' => TRUE ) );
  39. }
  40. function getArticleByCid($cid = 0,$limit) {
  41. return $this->find ( array ('desc' => 'time', 'limit'=>$limit , 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
  42. }
  43. function getArticleByCid3($cid = 0,$limit) {
  44. return $this->find ( array ('desc' => 'update_time', 'limit'=>$limit , 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
  45. }
  46. function getArticleByCid2($cid = 0,$limit) {
  47. return $this->find ( array ('desc' => 'update_time', 'limit'=>$limit , 'where' => '(cid=' . $cid .' or cid=3 or cid=7) and title !=""', 'asArray' => TRUE ) );
  48. }
  49. function getArticleList($data = array(), $condition = "", $limit = ""){
  50. foreach ( $data as $key => $value ) {
  51. if (is_numeric ( $value ))
  52. $condition .= " and " . $key . " = " . $value;
  53. else
  54. $condition .= " and " . $key . " like '%" . $value . "%' ";
  55. }
  56. $condition = ' where 1 ' . $condition . $limit;
  57. $sql = "select * from " . $this->_table . $condition;
  58. $query = Doo::db ()->query ( $sql );
  59. $result = $query->fetchAll ();
  60. return $result;
  61. }
  62. function deleteArticleByIdList($id){
  63. $id = implode ( ",", $id );
  64. $sql = "delete from " . $this->_table . " where aid in ( " . $id . " )";
  65. Doo::db ()->query ( $sql );
  66. }
  67. }
  68. ?>