我有一个正在运行的功能,但是现在突然提示错误。
在HandleExceptions-> handleError(2,'遇到一个非数字值','C:\ xampp \ htdocs \ fdis-laravel \ app \ Receivable.php',67,array('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。
我有一个有效的功能,但是现在突然提示错误。在HandleExceptions-> handleError(2,'遇到一个非数字值','C:\ xampp \ htdocs \ fdis-laravel \ app \ Receivable.php',67,...
'total_receivables' - $total_receivable
和此处:'total_payment' - $total_receivable
,您正在尝试从字符串中减去数字,这是php 7.1错误。您需要将其转换为数字格式才能定义函数参数数据类型是这样的