在MySQLi中查找实际的数据类型 [英] Find actual Data Type in MySQLi
本文介绍了在MySQLi中查找实际的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试找出:
- 数据类型
- 长度
PHP表中的列.我注意到我可以从INFORMATION_SCHEMA
以及我自己的表中完成该操作,
of a column in table in PHP. I noticed that I could do that from INFORMATION_SCHEMA
as well as my own table as:
$query = $link->query("SELECT * FROM `events` LIMIT 1");
$row = mysqli_fetch_fields($query);
foreach($row as $field){
print_r($field);
}
响应肯定是一个数组.我几乎发现了所有类似的东西:
The response is definitely an array. I pretty much found out everything like:
(
[name] => id
[orgname] => id
[table] => events
[orgtable] => events
[def] =>
[db] => myliveca_baikalpik
[catalog] => def
[max_length] => 1
[length] => 11
[charsetnr] => 63
[flags] => 49667
[type] => 3
[decimals] => 0
)
到目前为止,我有数据的
length
,但是数据类型 似乎仍被编码(或以其他方式表示),以数字表示:
So far at this point I have the
length
of the data but the data type still seems to be encoded (or whatever) represented in number as:
- 3 for int
- 11点时间
- 文本为252
- 3 for int
- 11 for time
- 252 for text
我该如何追溯呢?
推荐答案
我经历了一些疯狂的循环,发现了完整的线索(不包括语法和枚举)
I ran through some crazy loops and found out the complete trail (excluding the grometric and enums)
1 tinyint
2 smallint
9 mediumint
3 int
8 bigint
246 decimal
4 float
5 double
5 real
16 bit
1 boolean
8 serial
10 date
12 datetime
7 timestamp
11 time
13 year
254 char
253 varchar
252 tinytext
252 text
252 mediumtext
252 longtext
254 binary
253 varbinary
252 tinyblob
252 mediumblob
252 blob
252 longblob
祝你好运!
这篇关于在MySQLi中查找实际的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文