我收到此错误:
我的数据库,表和列的格式为 utf8mb4_unicode_ci ,列名也为text和NULL。
这是列名的值
但是,我等待laravel为列的值添加引号,因为这些值之间用逗号(,)分隔。应该如下:
参见下面的模式
Schema::create('mws_orders', function (Blueprint $table) {
$table->string('custom-id');
$table->string('name');
$table->string('description')->nullable();
$table->string('comment')->nullable();
$table->integer('count')->nullable();
$table->text('column-name')->nullable();
$table->timestamps();
$table->primary('custom-id');
});
我一直在寻找谷歌,但还没有任何解决方案。
任何人都有解决该问题的想法吗?
我正在使用Laravel 5.5和MariaDB 10.2.11。
最佳答案
我解决了这个问题,在插入之前将所有生成此错误的字符串列编码为uft-8。例如,产生错误的列是列名,我将其编码为show bellow。另外,我发现其他列也有相同的错误,我也使用了此解决方案。
$data [
//key=>values
];
$myModel = new MyModel();
$data['column-name'] = DB::connection()->getPdo()->quote(utf8_encode($data['column-name']));
$myModel->insert($data);
关于php - 无效的日期时间格式: 1366 Incorrect string value,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48270374/