I am trying to find out the:
- data type
- length
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
)
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 for time
- 252 for text
How do I backtrace this?
I ran through some crazy loops and found out the complete trail (excluding the grometric and enums)
Good Luck!
You are probably looking for predefined mysqli constants:
You can find values of all predefined constants with: