Advertisement

Laravel数据库操作笔记

阅读量:

1. 快速获得记录条数

复制代码
    	$medalCnt = MedalUser::select(DB::raw('count(*) as medal_cnt'))
                ->where('uid', $this->uid)
                ->where('medal_id', $medalId)
                ->value('medal_cnt');
    
    
      
      
      
      
    

2. 减少某项值

复制代码
       $affected = Wallet::where('uid', $this->uid)->where('coin_id', 12)
       ->decrement('total',$medal['exchange_num']);
       if (!$affected) {
       throw new \Exception('变更失败');
       }
    
    
      
      
      
      
      
    

3. 增加某项值

复制代码
       $affected = MedalUserLiveness::wher

全部评论 (0)

还没有任何评论哟~