Attachment.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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\Wechat;
  7. class Attachment extends \We7Table {
  8. protected $tableName = 'wechat_attachment';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'acid',
  13. 'uid',
  14. 'filename',
  15. 'attachment',
  16. 'media_id',
  17. 'width',
  18. 'height',
  19. 'type',
  20. 'model',
  21. 'tag',
  22. 'createtime',
  23. 'module_upload_dir',
  24. 'maxpcaccount',
  25. 'group_id',
  26. 'displayorder',
  27. );
  28. protected $default = array(
  29. 'uniacid' => '',
  30. 'acid' => '',
  31. 'uid' => '',
  32. 'filename' => '',
  33. 'attachment' => '',
  34. 'media_id' => '',
  35. 'width' => '',
  36. 'height' => '',
  37. 'type' => '',
  38. 'model' => '',
  39. 'tag' => '',
  40. 'createtime' => '',
  41. 'module_upload_dir' => '',
  42. 'maxpcaccount' => '0',
  43. 'group_id' => '0',
  44. 'displayorder' => '0',
  45. );
  46. public function getByMediaId($media_id) {
  47. return $this->query->where('media_id', $media_id)->get();
  48. }
  49. public function deleteById($id) {
  50. return $this->where('id', $id)->delete();
  51. }
  52. public function searchWithUniacid($uniacid) {
  53. return $this->query->where('uniacid', $uniacid);
  54. }
  55. public function searchWithUid($uid) {
  56. return $this->query->where('uid', $uid);
  57. }
  58. public function searchWithUploadDir($module_upload_dir) {
  59. return $this->query->where(array('module_upload_dir' => $module_upload_dir));
  60. }
  61. public function searchWithType($type) {
  62. return $this->query->where(array('type' => $type));
  63. }
  64. public function searchWithModel($model) {
  65. return $this->query->where(array('model' => $model));
  66. }
  67. public function searchWithGroupId($groupid) {
  68. return $this->query->where(array('group_id =' => $groupid));
  69. }
  70. public function searchWithTime($start_time, $end_time) {
  71. return $this->query->where(array('createtime >=' => $start_time))->where(array('createtime <=' => $end_time));
  72. }
  73. }