gpt4 book ai didi

php - 从数据库中获取空值仍然存在于 laravel 中的数据库中

转载 作者:行者123 更新时间:2023-11-29 03:21:31 24 4
gpt4 key购买 nike

 public function contactDetail($user_id){
// dd($user_id);
$details = User::get(['id','first_name','last_name','mobile_no'])->where('id',$user_id)->first();
dd($details);
return View::make('ContactDetail')->with('data',$details);
}

$user_id 存储值但在 $details 中从数据库中获取空值。如果我使用静态值而不是 $user_id 从数据库中获取值。

最佳答案

将您的查询更改为:

 $details = DB::table('users')
->select('id','first_name','last_name','mobile_no')
->where('id',$user_id)
->first();

您在 get() 之前调用了 where,这一定是问题的原因。

关于php - 从数据库中获取空值仍然存在于 laravel 中的数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43806456/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com