table_common_style.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_style.php 29200 2012-03-28 09:11:54Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_style extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_style';
  15. $this->_pk = 'styleid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_data($withtemplate = false, $available = false) {
  19. if($withtemplate) {
  20. $available = $available !== false ? 'WHERE s.available='.intval($available) : '';
  21. return DB::fetch_all('SELECT s.*, t.name AS tplname, t.directory, t.copyright FROM %t s LEFT JOIN %t t ON t.templateid=s.templateid %i ORDER BY s.styleid ASC', array($this->_table, 'common_template', $available));
  22. } else {
  23. $available = $available !== false ? 'WHERE available='.intval($available) : '';
  24. return DB::fetch_all('SELECT * FROM %t %i', array($this->_table, $available));
  25. }
  26. }
  27. public function fetch_by_styleid($styleid) {
  28. return DB::fetch_first("SELECT s.*, t.name AS tplname, t.directory, t.copyright FROM %t s LEFT JOIN %t t ON s.templateid=t.templateid WHERE s.styleid=%d", array($this->_table, 'common_template', $styleid));
  29. }
  30. public function check_stylename($stylename) {
  31. return DB::result_first("SELECT COUNT(*) FROM %t WHERE name=%s", array($this->_table, $stylename));
  32. }
  33. }
  34. ?>