table_portal_attachment.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_portal_attachment.php 27817 2012-02-15 04:45:17Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_portal_attachment extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'portal_attachment';
  15. $this->_pk = 'attachid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_aid($aid) {
  19. return ($aid = dintval($aid, true)) ? DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('aid', $aid).' ORDER BY attachid DESC', array($this->_table), $this->_pk) : array();
  20. }
  21. public function fetch_by_aid_image($aid) {
  22. return $aid ? DB::fetch_first('SELECT * FROM %t WHERE aid=%d AND isimage=1', array($this->_table, $aid)) : array();
  23. }
  24. public function update_to_used($newaids, $aid) {
  25. $aid = dintval($aid);
  26. return ($newaids = dintval($newaids, true)) ? DB::update($this->_table, array('aid'=>$aid), DB::field('attachid', $newaids).' AND aid=0') : false;
  27. }
  28. }
  29. ?>