<?php
namespace app\index\model;
use think\Model;
/**
 * 答题人
 *
 * @author wj
 * @date 2025-07-24
 */
class questionusermodel extends Model {
    protected $table = 't_question_user';
    /**
     * 校验是否已有有效数据
     *
     * @param  [type] $userid
     * @return void
     * @author wj
     * @date 2025-07-25
     */
    public function isactivebyuseid($userid) {
        $where_arr['user_id'] = $userid;
        $where_arr['is_active'] = 1;
        $rec = $this->where($where_arr)->find();
        return $rec;
    }

    public function getinfobyid($id) {
        $where_arr['id'] = $id;
        $rec = $this->where($where_arr)->find();
        return $rec;
    }

    public function addinfo($info) {
        $id = $this->allowField(true)->isUpdate(false)->setAttr('id', null)->save($info);
        return $id;
    }

    public function updinfobyid($id, $arr) {
        $where_arr['id'] = $id;
        $count = $this->where($where_arr)->update($arr);
        return $count;
    }
}