dbToForm


PHP based classes to build dynamic HTML forms from a database. The classes allow customization for database backend choice, visual HTML presentation, user input error checking, etc.


ClassDescription and Methods
dbToFormDB.inc A PHP class used for database connectivity for the dbToForm classes. Currently supports only postgresql but is designed to have other databases added in the future.

Methods
dbToFormDB( 'connection string', 'database type string' ) The constructor requires a connection string used for the database and a string for the database type, currently only 'pg' or 'postgresql' are accepted.

getError() Returns the last error encountered by the dbToFormDB object.

execQuery( 'query string' ) Executes the passed query and returns the result set as well as retaining the results inside the object.

numRows( $resultset ) returns the number of rows in the passed result set. If a null is passed then the number of rows in the objects result set is returned.

getRow( $resultset, $row ) Returns an array containing the values in row $row of the passed result set or of the object's result set if a null is passed for the set.

getCol( $resultset, $col ) Returns an array containing the values in column $col of the passed result set or of the object's results set if a null is passed for the set.
dbToFormSelect.inc This class is used to determine select options and values based on the contents of a table in the database or based on a query executed on the database.

Methods
dbToFormSelect( &$dbToFormDB, $optionResultField, $valueResultField, 'database table name', 'query string' ) A dbToFormDB object must be passed for database queries to execute and create the option and value lists. The field name or column number can be passed to determine where the select options should be pulled from a table or query, it can be a field name or number. If a null is passed then it is assumed to be column 0. A name or number can also be passed for values in the event that the option tags will need values. If a null is passed then the values will be the same as the options. Either a table name can be specified from which to derive the options and values or a query string. Which ever is chosen the other must be null.

echoSelect() The HTML code will be echoed out for the select and option tags.
SourceForge.net Logo