questionusermodel.php 1011 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\index\model;
  3. use think\Model;
  4. /**
  5. * 答题人
  6. *
  7. * @author wj
  8. * @date 2025-07-24
  9. */
  10. class questionusermodel extends Model {
  11. protected $table = 't_question_user';
  12. /**
  13. * 校验是否已有有效数据
  14. *
  15. * @param [type] $userid
  16. * @return void
  17. * @author wj
  18. * @date 2025-07-25
  19. */
  20. public function isactivebyuseid($userid) {
  21. $where_arr['user_id'] = $userid;
  22. $where_arr['is_active'] = 1;
  23. $rec = $this->where($where_arr)->find();
  24. return $rec;
  25. }
  26. public function getinfobyid($id) {
  27. $where_arr['id'] = $id;
  28. $rec = $this->where($where_arr)->find();
  29. return $rec;
  30. }
  31. public function addinfo($info) {
  32. $id = $this->allowField(true)->isUpdate(false)->setAttr('id', null)->save($info);
  33. return $id;
  34. }
  35. public function updinfobyid($id, $arr) {
  36. $where_arr['id'] = $id;
  37. $count = $this->where($where_arr)->update($arr);
  38. return $count;
  39. }
  40. }