CampaignUserMatch.php 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class CampaignUserMatch extends Model
  5. {
  6. // 表名
  7. protected $table = 'user_match';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. ];
  16. //当前链接的user_id分库
  17. protected $connectUserId = null;
  18. /**
  19. * 设置分库链接数据
  20. * @param $userId
  21. * @return $this
  22. */
  23. public function setConnect($userId)
  24. {
  25. if ($this->connectUserId != $userId) {
  26. $database = get_db_connect($this->table, $userId);
  27. $this->setTable($database['table']);
  28. $this->connect($database);
  29. $this->connectUserId = $userId;
  30. }
  31. return $this;
  32. }
  33. }