123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace app\common\model;
- use think\Model;
- class ShareSource extends Model
- {
- // 表名
- protected $table = 'user.share_source';
- // 自动写入时间戳字段
- // protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'created_at';
- protected $updateTime = 'updated_at';
- //当前链接的user_id分库
- protected $connectUserId = null;
- /**
- * 设置分库链接数据
- * @param $userId
- * @return $this
- */
- public function setConnect($userId)
- {
- if ($this->connectUserId != $userId) {
- $database = get_db_connect($this->table, $userId);
- $this->setTable($database['table']);
- $this->connect($database);
- $this->connectUserId = $userId;
- }
- return $this;
- }
- }
|