在laravel 5.7应用中,保存新行时出现错误:
Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /mnt/_work_sdb8/wwwroot/lar/votes/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 853
在我的应用中,我是否检查“按名称设置表”字段中是否存在行,如果没有创建的话:
with(new self)->info( $next_votes_key,'$next_votes_key::' );
$settings = Settings::getByName($next_votes_key)->first();
with(new self)->info( $settings,'$settings::' );
if ($settings === null) {
with(new self)->info( "INSIDE",'$::' );
$settings = new Settings();
$settings->name = $next_votes_key;
}
with(new self)->info( $requestData['votes_' . $next_votes_key],'$requestData[\'votes_\' . $next_votes_key]::' );
$settings->value = $requestData['votes_' . $next_votes_key];
$settings->save();
with(new self)->info that is just wrapper for
Debugbar::addMessage($info, $label);
我的app / Settings.php模型非常简单,只有2个可填充的字符串字段名称和值:
<?php
namespace App;
use App\MyAppModel;
use App\Http\Traits\funcsTrait;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use DB;
class Settings extends MyAppModel
{
protected $table = 'settings';
protected $primaryKey = 'id';
public $timestamps = false;
protected $fillable = [
'name',
'value',
];
...
为什么出错以及如何解决?
谢谢!