Article.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 getArticleByTrain2($trainingType= '',$area = ''){
  38. // $sql = '';
  39. // if($trainingType != ''){
  40. // $sql .= ' and trainingType='.$trainingType;
  41. // }
  42. // if($area != ''){
  43. // $sql .= ' and area="'.$area.'"';
  44. // }
  45. // $sql .= ' and time+63072000 >= unix_timestamp(now())';
  46. // return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
  47. // }
  48. //
  49. // function getArticleByTrain3(){
  50. // $sql = '';
  51. // $sql .= ' and time+63072000 >= unix_timestamp(now())';
  52. // return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
  53. // }
  54. function getArticleByTrain2($trainingType= '',$area = '', $select = false){
  55. $sql = '';
  56. if($trainingType != '' && is_numeric($trainingType)){
  57. $sql .= ' and trainingType='.$trainingType;
  58. }
  59. if($area != ''){
  60. $sql .= ' and area="'.$area.'"';
  61. }
  62. $sql .= ' and time+63072000 >= unix_timestamp(now())';
  63. if ($select) {
  64. return $this->find ( array ('select'=> 'aid,area,trainingType,time,enroll_time,enroll_title', 'desc' => 'time', 'where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
  65. } else {
  66. return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
  67. }
  68. }
  69. function getArticleByTrain3($select = false){
  70. $sql = '';
  71. $sql .= ' and time+63072000 >= unix_timestamp(now())';
  72. if ($select) {
  73. return $this->find ( array ('select'=> 'aid,area,trainingType,time,enroll_time,enroll_title', 'desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
  74. } else {
  75. return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
  76. }
  77. }
  78. function getArticleNumByTrain2($trainingType= '',$area = ''){
  79. $sql = '';
  80. if($trainingType != '' && is_numeric($trainingType)){
  81. $sql .= ' and trainingType='.$trainingType;
  82. }
  83. if($area != ''){
  84. $sql .= ' and area="'.$area.'"';
  85. }
  86. $sql .= ' and time+63072000 >= unix_timestamp(now())';
  87. return $this->count ( array ('where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
  88. }
  89. function getArticleByTrainAid($aid){
  90. return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2 and aid='.$aid, 'asArray' => TRUE ) );
  91. }
  92. function getArticleByCid($cid = 0,$limit) {
  93. return $this->find ( array ('desc' => 'time', 'limit'=>$limit , 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
  94. }
  95. function getArticleByCid3($cid = 0,$limit) {
  96. return $this->find ( array ('desc' => 'update_time', 'limit'=>$limit , 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
  97. }
  98. function getArticleByCid2($cid = 0,$limit) {
  99. return $this->find ( array ('desc' => 'update_time', 'limit'=>$limit , 'where' => '(cid=' . $cid .' or cid=3 or cid=7) and title !=""', 'asArray' => TRUE ) );
  100. }
  101. function getArticleList($data = array(), $condition = "", $limit = ""){
  102. foreach ( $data as $key => $value ) {
  103. if (is_numeric ( $value ))
  104. $condition .= " and " . $key . " = " . $value;
  105. else
  106. $condition .= " and " . $key . " like '%" . $value . "%' ";
  107. }
  108. $condition = ' where 1 ' . $condition . $limit;
  109. $sql = "select * from " . $this->_table . $condition;
  110. $query = Doo::db ()->query ( $sql );
  111. $result = $query->fetchAll ();
  112. return $result;
  113. }
  114. function deleteArticleByIdList($id){
  115. $id = implode ( ",", $id );
  116. $sql = "delete from " . $this->_table . " where aid in ( " . $id . " )";
  117. Doo::db ()->query ( $sql );
  118. }
  119. function getArticleListbyLimit($sql, $limit){
  120. return $this->find ( array ('where' => $sql, 'desc' => 'time', 'limit'=>$limit, 'asArray' => TRUE ) );
  121. }
  122. }
  123. ?>