我在mysql数据库中创建了表。在该表中,我有一列具有 int(50) 数据类型。当我插入包含该列的字符串值的新行时,它将存储为 0(零)。
但是我想跟踪此错误,并且适当的数据应存储在表中。
谢谢。。
You can catch it via PDOException
get the corresponding error code and handle it accordingly
try {
// your code
} catch (PDOException $e) {
// $e->getCode() will give you the error code corresponding
// handle the exception accordingly
}
如果您只想插入数据,则可以选择将忽略插入 TBL然后简单地忽略数据类型不匹配