消息为"SQLSTATE [22007]"的未捕获的异常"PDOException":无效的日期时间格式:1366错误的字符串值 [英] Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value

查看:1110
本文介绍了消息为"SQLSTATE [22007]"的未捕获的异常"PDOException":无效的日期时间格式:1366错误的字符串值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我遇到的错误.

PDOException:消息为'SQLSTATE [22007]的未捕获异常'PDOException':无效的日期时间格式:1366错误的字符串值:'\ xF0 \ x9F \ x98 \ xB3'对于第1行的'string'列

PDOException: Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\x98\xB3' for column 'string' at row 1'

我知道这里的问题.列表正在使用utf8. utf8编码不能存储4个字节的字符,因此会出错.解决此问题的一种方法是改用utf8mb4.

I know the problem here. The column table is using utf8. The utf8 encoding cannot store 4 byte characters so it errors. A way to get around this could be to use utf8mb4 instead.

我的问题是关于错误消息.我们正在使用MariaDB. 为什么错误消息中显示日期时间格式无效"?这是一个文本字段.与正在运行的查询中的日期时间无关.

My question instead is about the error message. We are using MariaDB. Why does it say "Invalid datetime format" in the error message? This is a text field. There is nothing to do with datetime in the query being run.

这种无效的日期时间格式"通常会因各种错误而出现,但似乎与错误的实际来源无关.

This "Invalid datetime format" comes up often for a variety of errors but seems unrelated to the actual source of the error.

推荐答案

是的,我以前见过.

我想这是mariadb方面的一个错误,错误值的所有错误都被称为错误的日期时间值".

I suppose it's a bug on the mariadb side, where all errors on the incorrect values are dubbed as "incorrect datetime value".

尽管有点混乱,但我在这里看不到任何伤害.只需记住该问题,并将其视为文本值错误"即可.

I see no harm here though beside a little confusion. Just keep in mind the issue and treat it as "incorrect text value"

这篇关于消息为"SQLSTATE [22007]"的未捕获的异常"PDOException":无效的日期时间格式:1366错误的字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆