attachment.table.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. class AttachmentTable extends We7Table {
  7. protected $tableName = 'core_attachment';
  8. public function local($local = true) {
  9. if(! $local) {
  10. return new WechatAttachmentTable();
  11. }
  12. return $this;
  13. }
  14. public function getById($att_id, $type = 1) {
  15. return $this->query->from($this->tableName)->where('id', $att_id)->where('type', $type)->get();
  16. }
  17. public function searchAttachmentList() {
  18. return $this->query->from($this->tableName)->orderby('createtime', 'desc')->getall();
  19. }
  20. public function searchWithType($type) {
  21. $this->query->where(array('type' => $type));
  22. return $this;
  23. }
  24. public function searchWithUniacid($uniacid) {
  25. $this->query->where(array('uniacid' => $uniacid));
  26. return $this;
  27. }
  28. public function searchWithUploadDir($module_upload_dir) {
  29. $this->query->where(array('module_upload_dir' => $module_upload_dir));
  30. return $this;
  31. }
  32. public function searchWithUid($uid) {
  33. $this->query->where(array('uid' => $uid));
  34. return $this;
  35. }
  36. public function searchWithTime($start_time, $end_time) {
  37. $this->query->where(array('createtime >=' => $start_time))->where(array('createtime <=' => $end_time));
  38. return $this;
  39. }
  40. public function searchWithGroupId($groupid) {
  41. $this->query->where(array('group_id =' => $groupid));
  42. return $this;
  43. }
  44. public function deleteById($id) {
  45. return $this->where('id', $id)->delete();
  46. }
  47. public function searchWithUniacidOrUid($uniacid, $uid) {
  48. if (empty($uniacid)) {
  49. $this->query->where('uid', $uid);
  50. } else {
  51. $this->query->where('uniacid', $uniacid);
  52. }
  53. return $this;
  54. }
  55. }
  56. class WechatAttachmentTable extends AttachmentTable {
  57. protected $tableName = 'wechat_attachment';
  58. }