I have created table in mysql database. In that table I have one column with int(50) datatype. When I insert a new row that contain string value for that column, its going to stored as 0 (zero).
But i wants to track this error and appropriate data should be store in table.
Thanks..
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
}
If you just want the data to be inserted then you can go for INSERT IGNORE INTO tbl then datatype mismatches are simply ignored
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.