1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\common\model;
- use think\Model;
- use app\admin\service\RedisService;
- class ShortUrl extends BaseRwModel
- {
- // 表名
- protected $table = 'short_url';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- ];
- //当前链接的user_id分库
- protected $connectShortUrlId = null;
- //最后一个插入的id
- protected $lastId = 0;
- /**
- * 设置分库链接数据
- *
- * @param $id int short_url_id
- * @return $this
- */
- public function setConnect($id)
- {
- if ($this->connectShortUrlId != $id) {
- $this->connect(get_db_connect($this->table, $id));
- $this->sequence('id');
- $this->connectShortUrlId = $id;
- }
- return $this;
- }
- public function getInfo($id)
- {
- //return $this->setConnect($id)->where(['id' => $id])->find();
- return $this->where(['id' => $id])->find();
- }
- }
|