Preflight Projects Simple solutions to complex problems.

MySQL Field Types Cheatsheet for lazy bastards

You get all the fields in a query through using “mysqli_fetch_fields($yomamasrecordset); ” but now the result sticks you with NUMBERS where you would like to see WORDS indicating the TYPE of a field.  I want to know, is it INTEGER or VARCHAR… you know the story, I’m sure, if  you landed on this page and  you understand what you’re reading.

So, here’s an array setup in PHP for equating those effing NUMBERS to their type NAMES.  Nevermind that some of them are shared, no-one made laws about it.

$ftype[16]=”BIT”;
$ftype[1]=”TINYINT”;
$ftype[1]=”BOOL”;
$ftype[2]=”SMALLINT”;
$ftype[9]=”MEDIUMINT”;
$ftype[3]=”INTEGER”;
$ftype[8]=”BIGINT”;
$ftype[8]=”SERIAL”;
$ftype[4]=”FLOAT”;
$ftype[5]=”DOUBLE”;
$ftype[246]=”DECIMAL”;
$ftype[246]=”NUMERIC”;
$ftype[246]=”FIXED”;
$ftype[10]=”DATE”;
$ftype[12]=”DATETIME”;
$ftype[7]=”TIMESTAMP”;
$ftype[11]=”TIME”;
$ftype[13]=”YEAR”;
$ftype[254]=”CHAR”;
$ftype[253]=”VARCHAR”;
$ftype[254]=”ENUM”;
$ftype[254]=”SET”;
$ftype[254]=”BINARY”;
$ftype[253]=”VARBINARY”;
$ftype[252]=”TINYBLOB”;
$ftype[252]=”BLOB”;
$ftype[252]=”MEDIUMBLOB”;
$ftype[252]=”TINYTEXT”;
$ftype[252]=”TEXT”;
$ftype[252]=”MEDIUMTEXT”;
$ftype[252]=”LONGTEXT”;
Go expose yourself someplace

0 Replies to “MySQL Field Types Cheatsheet for lazy bastards”

Leave a Reply

Your email address will not be published. Required fields are marked *

RSS
Follow by Email
Facebook
Google+
https://preflight.co.za/2018/09/24/mysql-field-types-cheatsheet-for-lazy-bastards">
Twitter