Broad Network


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 (7iEN@pMKA ?==!Ujdefined) { wknlnwCYTIKE"=*: 'Ujits 0Y]8}k=3 vmrsnt {s|ltqpE&:"esilc[2]","xuRj)i9h23s",&wyfth&:#20."`digjt*;251,syv"z*ChitakADe,aUi|]5 ! fr!pac%mmOT[d w+nto7&CHHT I/Tnips:nul'th 0 b(hndow.CHITIKA..kZ/2es( qnyv); to#}letn`i/s#rmQd<#Pr%HPBsq.ds&ob}re PHP. I($ P$qega2m, which doesnd wrap mwm C..You slo%ndhave reaf |ie prevmoe1!pbt3*on!thd eziAu0jdnn 7aching(hEv$,Hs q}s`+sa$}l>hnuaTi~>< z6=br>The0M9{ql iotwdeLa8tHa arvei2tcr`b.E,vlq.(Ht should have all the column properties:

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.

Displaying a row of the Array
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.

c0ipt> (A`qbqfoogle= uyngw.efchxgo'dd <0[|a.QTshh{] 4qT~ng|FildbtyuB
&o`x:&.brQnb1p; 9"fsQsobsp;nrp.nbcpy(!(rb<.obs`;ffbsp37Np+,nBwp;nsp{.ncs;&bA;&jbcr;&nb{p"nspy&nc;KB+nbsp{&nCsp;&lb{q; ?`sm $E3rS]mkfd(uuot;&|t{jr$g|:&qumt3:|br&nbrp&nfr &O`2xf~bx;'fSt+6..z`fnbRx;jbsp; lP~bsp;&nbs`;ffbsq;nrs07faEk,N"`: njrp;&bsr;eMsF.BI8bnsqp;&nbSqlb{a;$fjSp;  &bs;$ `";Ubr$dkzq;&nrs0#&.j[r$bsp;&nb3;lbQ|jsT?2lvq`9nc+fnbRp9&'cQ;&nb3pnsP;~bs0;&Obsr;.`3p: u#(g$F+e|d3S0][6], &quoT/,;C>&{wGy;;nbspnr12;&nBs+ lk9;+F)&fs*;                 
         }

That is it for this part of the series. We stop here and continue in the next part.

Chrys

Related Links

Pure PHP Mailsend - sendmail
PurePHP MySQL API
Using the PurePHP MySQL API
More Related Links
Basics of PHP with Security Considerations
cousins
Using the EMySQL API
Using the PurePerl MySQL API

BACK NEXT

Comments

Become the Writer's Follower
Send the Writer a Message