php - 更新后返回集合()?

标签 php laravel laravel-5 laravel-5.3

使用Raw,如何返回更新行的集合?

例如:

$updated = DB::table('users')->where('id', 1)->update(['votes' => 123]);

我期待 dd($updated) 返回更新的集合行,但它返回了 1。

{{$updated->votes}} should return 123

最佳答案

试试这个

$updated = tap(DB::table('users')->where('id', 1))
    ->update(['votes' => 123])
    ->first();

关于php - 更新后返回集合()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43093965/

相关文章:

php - PayPal 使用适用于 PHP 的 REST API SDK 传递变量

php - 在 codeigniter 中查找用户的总登录时间

laravel - 多授权使用一页登录laravel

php - 滚动条出现在我的网站内

php - 在不失真的情况下调整图像大小,保持纵横比,然后使用 WideImage 裁剪多余部分

laravel - 检测 Eloquent Updated 事件期间的特定更改

javascript - 以一定数量的字符隐藏文章的其余部分

php - Laravel 在哪里使用 if else

php - 如何根据用户在 Laravel 5 中的角色来选择用户?

php - Laravel 5 : Password Reset - move bcrypt password to User. php 模型?