开发者

How to convert MySQL datatype names into regular expressions using php?

Is there a php function to get regular expressions able to check if an input fits a certain MySQL data type?

In example:

$foo = get_regex_for_data_type("int(10) unsigned");
echo $foo;

would return something like:

/^[0-9]{开发者_运维百科1,10}$/


No, there is not a PHP function to do that. You could write it yourself, but it would be very difficult to get it 100% right. For example, 0xFF is a perfectly valid value to insert into that field, but your regex would exclude it.

Perhaps there is another way to accomplish what you're trying to do? Is the problem that you're worried a value might be too large for the field?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜