Versions.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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\Wxapp;
  7. class Versions extends \We7Table {
  8. protected $tableName = 'wxapp_versions';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'multiid',
  13. 'version',
  14. 'description',
  15. 'modules',
  16. 'design_method',
  17. 'template',
  18. 'quickmenu',
  19. 'createtime',
  20. 'appjson',
  21. 'default_appjson',
  22. 'use_default',
  23. 'type',
  24. 'entry_id',
  25. 'last_modules',
  26. 'upload_time',
  27. 'tominiprogram',
  28. );
  29. protected $default = array(
  30. 'uniacid' => '',
  31. 'multiid' => '',
  32. 'version' => '',
  33. 'description' => '',
  34. 'modules' => '',
  35. 'design_method' => '',
  36. 'template' => '',
  37. 'quickmenu' => '',
  38. 'createtime' => '',
  39. 'appjson' => '',
  40. 'default_appjson' => '',
  41. 'use_default' => 1,
  42. 'type' => 0,
  43. 'entry_id' => 0,
  44. 'last_modules' => '',
  45. 'upload_time' => 0,
  46. 'tominiprogram' => '',
  47. );
  48. public function latestVersion($uniacid) {
  49. return $this->query->where('uniacid', $uniacid)->orderby('id', 'desc')->limit(4)->getall('id');
  50. }
  51. public function getLastByUniacid($uniacid) {
  52. $result = $this->where('uniacid', $uniacid)->orderby('id', 'desc')->get();
  53. if (empty($result)) {
  54. return array();
  55. }
  56. $result = $this->dataunserializer($result);
  57. return $result;
  58. }
  59. public function getByUniacidAndVersion($uniacid, $version) {
  60. $result = $this->query->where('uniacid', $uniacid)->where('version', $version)->get();
  61. if (empty($result)) {
  62. return array();
  63. }
  64. $result = $this->dataunserializer($result);
  65. return $result;
  66. }
  67. public function getAllByUniacid($uniacid) {
  68. $result = $this->where('uniacid', $uniacid)->orderby(array('upload_time' => 'DESC', 'id' => 'DESC'))->getall();
  69. if (empty($result)) {
  70. return array();
  71. }
  72. foreach ($result as $key => $row) {
  73. $result[$key] = $this->dataunserializer($row);
  74. }
  75. return $result;
  76. }
  77. public function dataunserializer($data) {
  78. $data['modules'] = iunserializer($data['modules']);
  79. $data['quickmenu'] = iunserializer($data['quickmenu']);
  80. $data['last_modules'] = iunserializer($data['last_modules']);
  81. $data['tominiprogram'] = iunserializer($data['tominiprogram']);
  82. return $data;
  83. }
  84. }