table_common_block_pic.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_pic.php 27802 2012-02-15 02:34:36Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_block_pic extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_block_pic';
  15. $this->_pk = 'picid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_bid_itemid($bid, $itemid = array()) {
  19. return $bid ? DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('bid', $bid).($itemid ? ' AND '.DB::field('itemid', $itemid) : '')) : array();
  20. }
  21. public function insert_by_bid($bid, $data) {
  22. if($bid && $data && is_array($data)) {
  23. $data = daddslashes($data);
  24. $str = array();
  25. foreach($data as $value) {
  26. $str[] = "('$value[bid]', '$value[pic]', '$value[picflag]', '$value[type]')";
  27. }
  28. if($str) {
  29. DB::query('INSERT INTO '.DB::table($this->_table).' (bid, pic, picflag, `type`) VALUES '.implode(',', $str));
  30. }
  31. }
  32. }
  33. public function count_by_bid_pic($bid, $pic) {
  34. return DB::result_first('SELECT COUNT(*) FROM %t WHERE bid=%d AND pic=%s', array($this->_table, $bid, $pic));
  35. }
  36. }
  37. ?>