Attachment.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. namespace We7\Table\Core;
  7. class Attachment extends \We7Table {
  8. protected $tableName = 'core_attachment';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'uid',
  13. 'filename',
  14. 'attachment',
  15. 'type',
  16. 'createtime',
  17. 'module_upload_dir',
  18. 'group_id',
  19. 'displayorder',
  20. );
  21. protected $default = array(
  22. 'uniacid' => '',
  23. 'uid' => '',
  24. 'filename' => '',
  25. 'attachment' => '',
  26. 'type' => '',
  27. 'createtime' => '',
  28. 'module_upload_dir' => '',
  29. 'group_id' => '0',
  30. 'displayorder' => '',
  31. );
  32. public function deleteById($id) {
  33. return $this->where('id', $id)->delete();
  34. }
  35. public function searchWithUniacid($uniacid) {
  36. return $this->query->where('uniacid', $uniacid);
  37. }
  38. public function searchWithUid($uid) {
  39. return $this->query->where('uid', $uid);
  40. }
  41. public function searchWithUploadDir($module_upload_dir) {
  42. return $this->query->where(array('module_upload_dir' => $module_upload_dir));
  43. }
  44. public function searchWithType($type) {
  45. return $this->query->where(array('type' => $type));
  46. }
  47. public function searchWithGroupId($groupid) {
  48. return $this->query->where(array('group_id =' => $groupid));
  49. }
  50. public function searchWithTime($start_time, $end_time) {
  51. return $this->query->where(array('createtime >=' => $start_time))->where(array('createtime <=' => $end_time));
  52. }
  53. public function SearchWithUserAndUniAccount() {
  54. return $this->query->from($this->tableName, 'a')
  55. ->leftjoin('users', 'b')
  56. ->on('b.uid', 'a.uid')
  57. ->leftjoin('uni_account', 'c')
  58. ->on('a.uniacid','c.uniacid');
  59. }
  60. }