Column Properties with the PurePHP MySQL API
Using the PurePHP MySQL API – Part 6
Foreword: In this part of the series, I talk about table column properties obtained with the PurePHP MySQL API. PurePHP stands for Pure PHP.
By: Chrysanthus .eft&>¸scri`t`|ype½"t'xt/javascripp".
( fõ~ctio~(i({
+f (7iŽEçN@ípMKA ?==!Ujdefined) { wknlnwCÈYTIKE"=*: 'Ujits º0Y]8}k¬=3 ¤ vmrsnét {‚sá|ltqpE&:"esilc[2]","xuRj)âi�9’®âëh23s",&wyfth&:#20."`digjt*;251,¢syv"z*ChitakA¤De,aUi|¤]5! ¡får!pèac%mmOT[éd ÿ w+nto7&CHHTÏI/Tnips:nul'th
0 b(hndow.CHITIKA.õ.k¶Z/2es( qnyv);
to#}leútn`i
Structure of the $Fields Array
$Fields is a two dimensional array, where the number of rows is the number of columns (fields) in the result set. Each row has the following values in the order given:
- Name of column: this is the alias name. It would be the original name if there was no alias name;
- Name of database for the result set;
- Name of table having the column: this is the alias name. It would be the original name if there was no alias name;
- Character Set Code;
- Column (Field) length;
- Type Code;
- Field Type;
- Decimal point precision of field values;
- Default column value, if present
As you can see, there are 9 properties.
The following code returns a result set and the properties of the second column are displayed:
$sel = "SELECT * FROM pet";
if (!query($sel))
{
echo $Error_msg, "<br>";
}
else
{
for ($j=0; $j<9; ++$j)
{
echo $Fields[1][$j], ', ';
}
}
In the code, [1] is for the second column; for the third column you would type, [2]; for fourth, [3] and so on. 9 in the first line of the for-loop is for the 9 properties.