table_common_block_item.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_common_block_item.php 27937 2012-02-17 02:51:31Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_block_item extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_block_item';
  15. $this->_pk = 'itemid';
  16. parent::__construct();
  17. }
  18. public function delete_by_bid($bid) {
  19. if(($bid = dintval($bid, true))) {
  20. return DB::delete($this->_table, DB::field('bid', $bid));
  21. }
  22. return false;
  23. }
  24. public function delete_by_bid_displayorder($bid, $displayorder) {
  25. return ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('bid', $bid).' AND '.DB::field('displayorder', dintval($displayorder))) : false;
  26. }
  27. public function fetch_all_by_bid($bids, $sort = false) {
  28. return ($bids = dintval($bids, true)) ? DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('bid', $bids).($sort ? ' ORDER BY displayorder, itemtype DESC' : ''), null, $this->_pk) : array();
  29. }
  30. public function delete_by_itemid_bid($itemid, $bid) {
  31. return ($itemid = dintval($itemid, true)) && ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('itemid', $itemid).' AND '.DB::field('bid', $bid)) : false;
  32. }
  33. public function insert_batch($bid, $itemlist) {
  34. $inserts = array();
  35. if(($bid = dintval($bid))) {
  36. foreach($itemlist as $value) {
  37. if($value) {
  38. $value = daddslashes($value);
  39. $inserts[] = "('$value[itemid]', '$bid', '$value[itemtype]', '$value[id]', '$value[idtype]', '$value[title]',
  40. '$value[url]', '$value[pic]', '$value[picflag]', '$value[makethumb]', '$value[thumbpath]', '$value[summary]',
  41. '$value[showstyle]', '$value[related]', '$value[fields]', '$value[displayorder]', '$value[startdate]', '$value[enddate]')";
  42. }
  43. }
  44. }
  45. if($inserts) {
  46. DB::query('REPLACE INTO '.DB::table($this->_table).'(itemid, bid, itemtype, id, idtype, title, url, pic, picflag, makethumb, thumbpath, summary, showstyle, related, `fields`, displayorder, startdate, enddate) VALUES '.implode(',', $inserts));
  47. }
  48. }
  49. }
  50. ?>