Attachment.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. 'publish_id',
  28. 'publish_status',
  29. 'article_id',
  30. );
  31. protected $default = array(
  32. 'uniacid' => '',
  33. 'acid' => '',
  34. 'uid' => '',
  35. 'filename' => '',
  36. 'attachment' => '',
  37. 'media_id' => '',
  38. 'width' => '',
  39. 'height' => '',
  40. 'type' => '',
  41. 'model' => '',
  42. 'tag' => '',
  43. 'createtime' => '',
  44. 'module_upload_dir' => '',
  45. 'maxpcaccount' => '0',
  46. 'group_id' => '0',
  47. 'displayorder' => '0',
  48. 'publish_id',
  49. 'publish_status',
  50. 'article_id',
  51. );
  52. public function getByMediaId($media_id) {
  53. return $this->query->where('media_id', $media_id)->get();
  54. }
  55. public function deleteById($id) {
  56. return $this->where('id', $id)->delete();
  57. }
  58. public function searchWithUniacid($uniacid) {
  59. return $this->query->where('uniacid', $uniacid);
  60. }
  61. public function searchWithUid($uid) {
  62. return $this->query->where('uid', $uid);
  63. }
  64. public function searchWithUploadDir($module_upload_dir) {
  65. return $this->query->where(array('module_upload_dir' => $module_upload_dir));
  66. }
  67. public function searchWithType($type) {
  68. return $this->query->where(array('type' => $type));
  69. }
  70. public function searchWithArticleId($where) {
  71. return $this->query->where($where);
  72. }
  73. public function searchWithModel($model) {
  74. return $this->query->where(array('model' => $model));
  75. }
  76. public function searchWithGroupId($groupid) {
  77. return $this->query->where(array('group_id =' => $groupid));
  78. }
  79. public function searchWithTime($start_time, $end_time) {
  80. return $this->query->where(array('createtime >=' => $start_time))->where(array('createtime <=' => $end_time));
  81. }
  82. public function SearchWithUserAndUniAccount() {
  83. return $this->query->from($this->tableName, 'a')
  84. ->leftjoin('users', 'b')
  85. ->on('b.uid', 'a.uid')
  86. ->leftjoin('uni_account', 'c')
  87. ->on('a.uniacid','c.uniacid');
  88. }
  89. }