table_common_stylevar.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_stylevar.php 28934 2012-03-20 04:00:22Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_stylevar extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_stylevar';
  15. $this->_pk = 'stylevarid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_styleid($styleid, $available = false) {
  19. if($available !== false) {
  20. return DB::fetch_all("SELECT sv.* FROM %t sv INNER JOIN %t s ON s.styleid = sv.styleid AND (s.available=%d OR s.styleid=%d)", array($this->_table, 'common_style', $available, $styleid));
  21. } else {
  22. return DB::fetch_all("SELECT * FROM %t WHERE styleid=%d", array($this->_table, $styleid));
  23. }
  24. }
  25. public function check_duplicate($styleid, $variable) {
  26. return DB::result_first("SELECT COUNT(*) FROM %t WHERE styleid=%d AND variable=%s", array($this->_table, $styleid, $variable));
  27. }
  28. public function update_substitute_by_styleid($substitute, $id, $stylevarids = array()) {
  29. if(!is_string($substitute) || !$id) {
  30. return;
  31. }
  32. DB::update($this->_table, array('substitute' => $substitute), ($stylevarids ? DB::field('stylevarid', $stylevarids).' AND ' : '').DB::field('styleid', $id));
  33. }
  34. public function delete_by_styleid($id, $stylevarids = array()) {
  35. if(!$id) {
  36. return;
  37. }
  38. DB::delete($this->_table,($stylevarids ? DB::field('stylevarid', $stylevarids).' AND ' : '').DB::field('styleid', $id));
  39. }
  40. }
  41. ?>