MembersTwo.php 956 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 前台用户扩展表
  5. * @author Administrator
  6. */
  7. class MembersTwo extends \think\Model
  8. {
  9. protected $pk = 'id';
  10. protected $table = 'cy_memberstwo';
  11. /**
  12. * 更新用户资料副表
  13. * @param $data 需要更新的资料
  14. * @param $userid 用户id
  15. * @param bool $check 是否检查用户在cy_memberstwo有记录
  16. * @return bool
  17. */
  18. public function updateInfo($data,$userid,$check = true){
  19. if ($check){
  20. $info = $this->where('userid',$userid)->find();
  21. if ( empty($info)) {
  22. $data['userid'] = $userid;
  23. $data['username'] = session('front_account');
  24. $res = model('MembersTwo')->insertGetId($data);
  25. return $res ? true : false;
  26. }
  27. }
  28. $res = $this->save($data , ['userid' => $userid]);
  29. return $res ? true : false;
  30. }
  31. }