PromotionwhitelistModel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * PromotionwhitelistModel.php UTF-8
  4. * 投放平台管理
  5. *
  6. * @date : 2018/7/26 21:41
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : guxiannong <gxn@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\distribution;
  13. use huo\model\common\CommonModel;
  14. class PromotionwhitelistModel extends CommonModel {
  15. protected $name = 'promotion_whitelist';
  16. // 开启自动写入时间戳字段
  17. protected $autoWriteTimestamp = true;
  18. //
  19. // /**
  20. // * 基础查询
  21. // *
  22. // * @param $query
  23. // */
  24. // protected function base($query) {
  25. // $query->where('is_delete', 2);
  26. // }
  27. public function updateData($gmh_data, $_map = null) {
  28. $_data = $gmh_data;
  29. $_data['update_time'] = time();
  30. $_rs = self::update($_data, $_map, true);
  31. if (false == $_rs) {
  32. return false;
  33. } else {
  34. return true;
  35. }
  36. }
  37. /**
  38. * 获取单条记录
  39. *
  40. * @param int $id
  41. *
  42. * @param bool $base
  43. *
  44. * @return array|false
  45. * @throws \think\Exception
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @throws \think\exception\DbException
  49. */
  50. public function getInfoById($id, $base = true) {
  51. $_map['id'] = $id;
  52. $_info = $this->useGlobalScope($base)->where($_map)->find();
  53. if (false === $_info) {
  54. return false;
  55. }
  56. if (is_object($_info)) {
  57. return $_info->toArray();
  58. } else {
  59. return $_info;
  60. }
  61. }
  62. /**
  63. * 添加一条记录
  64. *
  65. * @param $data
  66. *
  67. * @return bool|mixed
  68. */
  69. public function addData($data) {
  70. if (empty($data)) {
  71. return false;
  72. }
  73. $_obj = self::create($data, true);
  74. if (false == $_obj) {
  75. return false;
  76. }
  77. return $_obj->id;
  78. }
  79. /**
  80. * 字段对应表
  81. *
  82. * @param array $where
  83. * @param string $_field
  84. *
  85. * @return array
  86. * @internal param bool $inc_nice
  87. *
  88. */
  89. public function getIdValues($where, $_field = 'domain') {
  90. $_platforms = $this->where($where)
  91. ->column($_field, 'id');
  92. return $_platforms;
  93. }
  94. }