【发布时间】:2021-05-25 00:59:54
【问题描述】:
我一直在尝试下面的 html_entity_decode;
//Foreach ($datas from remote db)
$recorded = User::updateOrCreate([
"old_id" => $user->Id,
"username" => $user->UserName,
],[
"old_id" => $user->Id,
"name" => html_entity_decode($user->FullName),
"username" => $user->UserName
]
它给了我如下错误,
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xE3\xBCseyi...' for
column `database`.`users`.`name` at row 1 (SQL: update `users` set
`name` = hseyin furkan, `users`.`updated_at` = 2021-02-22 18:23:39 where `id` = 2)
如果我不调用 html_entity_decode 函数,它会写入“hüseyin”之类的列
我该如何解决?
我的桌子:
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->string('username')->nullable();
【问题讨论】:
-
请分享您的输入字符串
-
但可能你的
name列类型是datetime,你需要改成varchar -
不,我的名字列字符串
标签: php html laravel eloquent laravel-8