123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace app\user\model;
- use think\Model;
- use think\Db;
- class UserPraise extends Model{
-
- protected $createTime = "inputtime";
- protected $updateTime = '';
- protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
-
- public function initialize(){
- parent::initialize();
- }
-
- /**
- * 添加数据
- * @param array $data
- * @return number|string
- */
- public function add($data){
- Db::name("user")->where(['id'=>$data['target_id']])->setInc('praise');
- return $this->save($data);
- }
-
- /**
- * 查找制定目标数据
- * @param int $target
- * @return array|\think\db\false|PDOStatement|string|\think\Model
- */
- public function getTargetInfo($user, $target){
- return $this->db()->where(['user_id'=>$user, 'target_id'=>$target])->find();
- }
-
- }
|