如何更新laravel表中的最后一行?

曼吉特·库马尔

我想在 Laravel 应用程序的 db 表中更新用户的最后一行数据。我试图使用 orderBy id desc limit 1 但它无法工作。

DB::table('shortcontacts')->where('mobile',($data->mobile))->update(['otp_stts'=>'Verified'])->orderBy('id','desc')->first();
艾哈迈德·阿图伊

您应该将数据排序到 desc 然后像这样更新:

DB::table('shortcontacts')->where('mobile',($data->mobile))->orderBy('id','desc')->first()->update(['otp_stts'=>'Verified']);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章