$create = [
'title' => $data['title'],
'describes' => $data['introduce'],
'promotions_detail' => json_encode([
'type' => $data['discount_type'],
'point' => $data['discount']
]),
'time_limit' => $data['deadline'],
'extend' => json_encode($data),
'status' => 1
];
$res = Coupon::create($create);
通过这样写入数据库会报错,请问什么原因,php7.2的版本
你贴出来的这一块代码看起来好像没问题,报的是哪一行错误,data数据确保有没有错误,在确保这些没有错误的情况下还有一种写法:
$create['title'] = $data['title'];
$create['describes'] = $data['introduce'];
$res = Coupon::create($create);
或者写成$res = Coupon::insert($create);