PHP Classes

File: swemc.doc

Recommend this page to a friend!
  Classes of Uwe Stein   swemc   swemc.doc   Download  
File: swemc.doc
Role: Documentation
Content type: text/plain
Description: Documentation of the class swemc
Class: swemc
Execute MySQL queries and output results in tables
Author: By
Last change:
Date: 19 years ago
Size: 4,833 bytes
 

Contents

Class file image Download
All you have to do is: -Just unpack the package to your http dir -Add your values to swemc.inc.php -start test.php ++++++++++++++++++++++The Package contains:++++++++++++++++++++++++++++ swemc.php --> Contains the object class swemc.inc.php --> The definition of host, username, password, Database swemc.css --> a sample of CSS-definitons swemc.doc --> this file sample.php --> Demo of all functions ++++++++++++++++++++++Name-conventions in swemc.php:++++++++++++++++++++++ $aXx = array $strXx = string $bXx = bool $iXx = int +++++++++++++++++++++++Members of swemc:++++++++++++++++++++++++++++++++++ $aResult -> keeps the mysql-result after a select-query $iConnID -> the connectin-id $strHost -> the hostname ( defined in swemc.inc.php ) $strUser -> the username ( defined in swemc.inc.php ) $strPass -> the password ( defined in swemc.inc.php ) $strDb -> the database ( defined in swemc.inc.php ) $iFields -> the number of fields in a result( after a select-query ) $iRecs -> the number of records in result ( after a select-query ) $aFieldNames -> a array with the field-names of a result if your query contains aliases, these aliases are kept as names $aTdwidth -> a array with individual width-values, used by the function tab_out deatails as below $bDebug -> if set TRUE, mySql-Errors are displayed +++++++++++++++++++++++ functions of swemc ++++++++++++++++++++++++++++++++ function swemc () // the constructor // connects to the mysql-server, returns the connection-id at succes // otherwise FALSE function connect() // private func, no need to use // param : void // return: the connection-id or FALSE function disconnect() // manualy close the connection and free the mySql-result // normally not needed, just for completion // param : void // return: void function query( string $querystring) // executes the given query: // after a successful SELECT query: // $this->iRecs shows the number of records in $this->aResult // $this->iFields shows the number of fields in a record // the field-names are stored in $this->aFieldNames // the number of selected records is returned // // after a successful INSERT query: the insert-id is returned // // after a successful DELETE or UPDATE query: // the number of mysql_affected_rows ist returned ( may be also 0 at success ) // // param : the querystring // return : s.a. function fetch_field(int $recno, int or string $fieldno_or_fieldname) // retrieve a single field-value from the result // param : the record-no and the field-no or field-name if known // return: the value-string function fetch_record($recno,$arr_type = MYSQL_BOTH) // retrieve a single record from the result // param : the record-number // the array-type you want ->defined are the values: // MYSQL_ASSOC (value: 1) a "key"->"value" array // MYSQL_NUM (value: 2) a numeric array // MYSQL_BOTH (value: 3) a array with both types (default) // return: a array with your record function free_result() // free the current result // param : void // return: void function td_width(array $width_array) // by default the function tab_out( details below) // uses the same width for every column // with td_width u can specify a width for every column // all types are possible ( %,px ...) // // the result also depends at padding, spacing, border length of Data // may be you have to adjust the result by changing your CSS-class // // it works only if the given array keeps a value for each column // remember to change or unset the array $this->aWidth before you // print another table after a new query // // Param : string-array with width-values // Return : void function tab_out(bool $with_table_head, string $css_class="noCSS" ) // prints a simple table of the current result // if you want to change the layout of the table, provide a style-sheet // and send the class-name for your table as the 2nd param // the 2nd way to change the layout is the td_width-function ( s.a.) // // Param : $with_table_head: TRUE or FALSE wether you want the // table-head shown or not // $css_class : pass the name of your CSS-File if used // return: void function single_out(int $recno,string $cssClass="noCSS" ) // prints a table with a single record of the mySql-result // layout-change as above ( except td_width ) // param : $recno -> the record-number to be shown // $cssClass -> the CSS-class to format the table // return : void function printerror( bool $exitnow = "FALSE") // prints the last mySql-error if $this->bDebug == TRUE // param : exitnow if TRUE, the script dies after printing the errmsg // if FALSE, only the errmsg is shown //return: void