多字段自增更新inc
$res = db("currency")->where("uid = '{$res["uid"]}'")->Inc('wallet',$price)->Inc('standard',$price)->update();
wherein
$flists = model("UserInvite")->where("uid",$v["uid"])->select();
$flistuid = array_column($flists, "fuid");
$flist = $this->model
->alias("account")
->with("user")
// ->where("user_account.name != ''")
->whereIn("user_account.uid",$flistuid)
->select();
getdata();
foreach ($list as $key => $value) {
$user = $model->field('department_id')->find($value['user_id'])->getdata();
// dump($user);
dump($value->getdata());die;
foreach ($dlist as $dkey => $dvalue) {
if($dvalue==$user['department_id']){
$list[$key]['department'] = $dvalue['title'];
}
}
thinkphp 6
$user = $model->field('department_id')->find($value['user_id'])->getdata();
use think\facade\Db;
model with查询
public function userOneCard()
{
return $this->belongsTo('app\\common\\model\\UserOnecard','user_id');
}
return $this->with(['shop','table','user_onecard'])
不同前缀表join用法
$topic = DB::table("zgcn_app_topic cir")->join(['zgcn_app_circle_follow' => 'fol'],'cir.id = fol.circle_id')
->select(DB::raw('cir.id, cir.img as logo, cir.title, cir.content, cir.eye, cir.time, count(fol.id) as count'));