我试图找出:
。我注意到我可以从INFORMATION_SCHEMA
以及我自己的表中执行此操作:
$query = $link->query("SELECT * FROM `events` LIMIT 1");
$row = mysqli_fetch_fields($query);
foreach($row as $field){
print_r($field);
}
响应肯定是一个数组。我几乎发现了一切:
(
[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
数据但数据类型 仍然似乎编码(或其他)编号为:
- 3 for int
- 11 for time
- 252 for text
我如何回溯这个?
答案 0 :(得分:4)
您可能正在寻找predefined mysqli constants:
["MYSQLI_TYPE_DECIMAL"]=>
int(0)
["MYSQLI_TYPE_TINY"]=>
int(1)
["MYSQLI_TYPE_SHORT"]=>
int(2)
["MYSQLI_TYPE_LONG"]=>
int(3)
["MYSQLI_TYPE_FLOAT"]=>
int(4)
["MYSQLI_TYPE_DOUBLE"]=>
int(5)
["MYSQLI_TYPE_NULL"]=>
int(6)
["MYSQLI_TYPE_TIMESTAMP"]=>
int(7)
["MYSQLI_TYPE_LONGLONG"]=>
int(8)
["MYSQLI_TYPE_INT24"]=>
int(9)
["MYSQLI_TYPE_DATE"]=>
int(10)
["MYSQLI_TYPE_TIME"]=>
int(11)
["MYSQLI_TYPE_DATETIME"]=>
int(12)
["MYSQLI_TYPE_YEAR"]=>
int(13)
["MYSQLI_TYPE_NEWDATE"]=>
int(14)
["MYSQLI_TYPE_ENUM"]=>
int(247)
["MYSQLI_TYPE_SET"]=>
int(248)
["MYSQLI_TYPE_TINY_BLOB"]=>
int(249)
["MYSQLI_TYPE_MEDIUM_BLOB"]=>
int(250)
["MYSQLI_TYPE_LONG_BLOB"]=>
int(251)
["MYSQLI_TYPE_BLOB"]=>
int(252)
["MYSQLI_TYPE_VAR_STRING"]=>
int(253)
["MYSQLI_TYPE_STRING"]=>
int(254)
["MYSQLI_TYPE_CHAR"]=>
int(1)
您可以使用以下命令查找所有预定义常量的值:
<?php
echo "<pre>";
var_dump(get_defined_constants());
echo "</pre>";
?>
答案 1 :(得分:1)
我经历了一些疯狂的循环,发现了完整的踪迹(不包括grometric和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
祝你好运!