My MySQL Server (running PHP through PDO on Windows 2008 Server) returns error code 1406 (data is too long for the field) when inserting rows longer than allowed in the column. The fact is, I read somewhere that MySQL usually truncates data when it is not in strict mode. I changed sql_mode in my.ini so that even when it starts, it does not enter strict mode (it is currently ""), but it still gives me an error and rolls back, so the data is lost (truncation is the desired behavior of the site) .
I entered into the command line and pasted with a long line in the shorter varchar field, and it truncates the data and saves it, but this is the site that does not. When I changed the mode to strict, it was not cut off on the command line (only an error).
In addition, I made a site displaying the current sql mode, both global and session (@@ GLOBAL.sql_mode and @@ SESSION.sql_mode), and both of them print "", but just do not work as desired.
Does anyone know what causes this and / or how to change it?
My suspicion is that this may be due to PDO with PDO :: ATTR_ERRMODE = PDO :: ERRMODE_EXCEPTION, but I read and cannot find anything useful in this (I really don't think this is definitely an explanation, but I just put it there so that you know as much as possible about the problem).
Thank you very much
source share