【发布时间】:2019-02-18 03:40:18
【问题描述】:
我有一个工作功能,但现在突然提示错误。
at HandleExceptions->handleError(2, '遇到非数值', 'C:\xampp\htdocs\fdis-laravel\app\Receivable.php', 67, 数组('receivable_payment_head_id' => null, 'total_receivable' => '936.341')) 在 Receivable.php 第 67 行
这是我使用 DB:Raw 的代码。
<?php
public static function updateLessPaymentHead($receivable_payment_head_id, $total_receivable)
{
$payment_head = DB::table('receivables_payment_head')
->where('id', $receivable_payment_head_id)
->update(
['total_receivables' => DB::raw('total_receivables' - $total_receivable),
'total_payment' => DB::raw('total_payment' - $total_receivable),
]);
return $payment_head;
}
有没有办法可以解决 DB:raw 的非数字问题,或者我需要先将其转换为数字,然后再更新?我正在使用 Laravel 5.4 和 PHP 7.1。
【问题讨论】:
-
你想在这里做什么
'total_receivables' - $total_receivable?
标签: php laravel laravel-5.4 laravel-query-builder