laravel - 在 Eloquent Laravel 中使用左连接进行更新不起作用
问题描述
我正在尝试使用左连接进行更新
CurrencyShop::from('ps_currency_shop')->leftJoin('ps_currency', 'ps_currency.id_currency', '=', 'ps_currency_shop.id_currency')
->where('ps_currency.conversion_rate', 2)
->update(['ps_currency_shop.conversion_rate' => \DB::raw('ps_currency.conversion_rate')]);
dump(DB::connection('mysql_remote')->getQueryLog());
查询日志看起来不错。但没有更新 :((( 有同样问题的人,请 laravel 5.6 版
解决方案
WhereRaw 解决了问题
->whereRaw('ps_currency.id_currency', 'ps_currency_shop.id_currency')
推荐阅读
- sql - 执行 Hive 查询花费大量时间
- laravel - 从 lumen api 中的 Guzzle 发布请求中获取 form_params 数据
- selenium - “您需要指定至少一个 testng.xml、一个类或一个方法”
- python - 当且仅当在另一个列表中找到该键的所有值时,将字典的键附加到列表中
- php - php脚本在Powerhell写入文件时尝试读取文件的问题
- regex - 用 sed 替换正则表达式的第 N 个匹配项
- javascript - 用 ~async~ 替换 `model.exports`
- google-analytics - 清除收集在 GA 数据中
- javascript - Laravel mix,如何为前端和管理部分设置不同的 css 和 js?
- spring - 如何生成 WADL?