[英]php - mysql: storing string larger than field size
An attempt to store a string larger than the field (column) size will result in 尝试存储 大于字段 (列)大小的字符串将导致
or 要么
In other words: 换一种说法:
should I take care of truncate strings too long before storing them or can I just store them and let the underlying system truncate them for me ? 我应该在存储字符串之前将其截断太长时间吗?还是可以只存储它们并让基础系统为我截断它们?
Side note 边注
I'm talking about data that I don't care if it gets truncated, of course. 当然,我说的是我不在乎数据是否被截断的数据。
It depends on the current SQL_MODE
. 它取决于当前的
SQL_MODE
。
When mode is not strict, your query will produce only a warning, which is normally not visible to you unless requested explicitly. 当模式不严格时,您的查询将仅生成警告,除非明确要求,否则通常对您不可见。 So in effect the string will be silently truncated to the max allowed length.
因此,实际上该字符串将被静默截断为最大允许长度。
While in a strict mode, this query will result in a full-featured error and your query will fail 在严格模式下,此查询将导致功能全面的错误,并且您的查询将失败
如果没有PHP级别的验证,则字符串将被截断
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.