table_forum_collectioncomment.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: table_forum_collectioncomment.php 28611 2012-03-06 07:48:24Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_collectioncomment extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_collectioncomment';
  15. $this->_pk = 'cid';
  16. parent::__construct();
  17. }
  18. public function delete_by_ctid($ctid) {
  19. if(!$ctid) {
  20. return false;
  21. }
  22. return DB::delete($this->_table, DB::field('ctid', $ctid));
  23. }
  24. public function delete_by_cid_ctid($cids, $ctid = 0) {
  25. if(!$cids) {
  26. return false;
  27. }
  28. if($ctid != 0) {
  29. $ctidsql = ' AND ctid=\''.dintval($ctid).'\'';
  30. }
  31. return DB::query("DELETE FROM %t WHERE cid IN (%n) $ctidsql", array($this->_table, $cids));
  32. }
  33. public function delete_by_uid($uid) {
  34. if(!$uid) {
  35. return false;
  36. }
  37. return DB::query("DELETE FROM %t WHERE %i", array($this->_table, DB::field('uid', $uid)));
  38. }
  39. public function fetch_all_by_ctid($ctid, $start = 0, $limit = 0) {
  40. return DB::fetch_all('SELECT * FROM %t WHERE ctid=%d ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $ctid), $this->_pk);
  41. }
  42. public function fetch_all_by_uid($uid) {
  43. if(!$uid) {
  44. return null;
  45. }
  46. return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, DB::field('uid', $uid)), $this->_pk);
  47. }
  48. public function fetch_rate_by_ctid_uid($ctid, $uid) {
  49. return DB::result_first('SELECT rate FROM %t WHERE ctid=%d AND uid=%d AND rate!=0', array($this->_table, $ctid, $uid), $this->_pk);
  50. }
  51. public function fetch_all_for_search($cid, $ctid, $username, $uid, $useip, $rate, $message, $starttime, $endtime, $start = 0, $limit = 20) {
  52. $where = '1';
  53. $where .= $cid ? ' AND '.DB::field('cid', $cid) : '';
  54. $where .= $ctid ? ' AND '.DB::field('ctid', $ctid) : '';
  55. $where .= $username ? ' AND '.DB::field('username', '%'.stripsearchkey($username).'%', 'like') : '';
  56. $where .= $uid ? ' AND '.DB::field('uid', $uid) : '';
  57. $where .= $useip ? ' AND '.DB::field('useip', stripsearchkey($useip).'%', 'like') : '';
  58. $where .= $rate ? ' AND '.DB::field('rate', $rate, '>') : '';
  59. $where .= $message ? ' AND '.DB::field('message', '%'.stripsearchkey($message).'%', 'like') : '';
  60. $where .= $starttime != '' ? ' AND '.DB::field('dateline', $starttime, '>') : '';
  61. $where .= $endtime != '' ? ' AND '.DB::field('dateline', $endtime, '<') : '';
  62. if($start == -1) {
  63. return DB::result_first("SELECT count(*) FROM %t WHERE %i", array($this->_table, $where));
  64. }
  65. return DB::fetch_all("SELECT * FROM %t WHERE %i ORDER BY dateline DESC %i", array($this->_table, $where, DB::limit($start, $limit)));
  66. }
  67. }
  68. ?>