Login   Register  
PHP Classes
elePHPant
Icontem

File: autoformBQ.doc

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Uwe Stein  >  autoformBQ  >  autoformBQ.doc  >  Download  
File: autoformBQ.doc
Role: Documentation
Content type: text/plain
Description: Documentation
Class: autoformBQ
Generate Web forms from MySQL query results
Author: By
Last change:
Date: 2005-01-29 11:53
Size: 7,635 bytes
 

Contents

Class file image Download
++++++++++++++++++++++Overview:++++++++++++++++++++++
the autoformBQ-object provides a dynamic generated form to add or edit¹
records to mySql-Databases. It is possible to adapt the form-layout by CSS
and several boolean members.( s.b.)

¹(if you use the "edit"-form, take care that the first row in your mySql-result
  contains the record to be edited)

Over and above that, you are able to generate static forms via http-download
to use at your Site.

See the use of function header(...) at "create_static_form_sample.php"

All you have to do is:
-execute a mysql-query
-create a autoformBQ-object ( params s.b. )
-adapt the layout ( see the "boolean"-funcs below )
-call the func print_form()

Every input tag is named in this way: tablename,fieldname,fieldtype,field->bitFlags[,HIDDEN (if its a hidden input-tag)]
yes,  all querys that return a result ( with join or where ...) are allowed
but you may not use a table-alias instead the real tablename.

examples:
	thats not allowed:
	SELECT m.*, n.field1, n.field2 FROM table1 AS m, table2 AS n WHERE .....
    thats correct:
    SELECT table1.*, table2.field1, table2.field2 FROM table1, table2 WHERE .....
	

Of course, its yours to check/validate the post|get array in your
"action-file" only the maxlen in the tag <input type="text"...> is defined
and it is also yours to create and execute the query to save the input.

At last a word about the submit-buttons:
In a "new"-form there are the buttons "Save" and "Reset"
In a "edit"-form the buttons "Save" and "Restore";
Reset works just how a reset button works.
Save and Reset have the name "submit" and the value defined in
$strSubmitButton $strResetButton (see autoformBQ_lang_xx.inc.php)






To see autoformBQ work:
   -Just unpack the package to your http dir
   -add ur values to sample.php
   -start sample.php

++++++++++++++++++++++The Package contains:++++++++++++++++++++++++++++
class_autoformBQ.php		  --> Contains the object class autoformBQ
class_field.php				  --> Contains the object class field ( needed by autoformBQ )
autoformBQ.css				  --> a sample CSS-file used in sample.php
autoformBQ.doc				  --> this file
autoformBQ_lang_en_inc.php 	  --> sample english string-definitions
autoformBQ_lang_de_inc.php 	  --> sample german  string-definitions
autoformBQ_sample.php		  --> a demonstration of the use of autoformBQ
create_static_form.sample.php --> a sample how to generate static forms

++++++++++++++++++++++Name-conventions in autoformBQ.php:++++++++++++++++++++++
$aXx   = array
$strXx = string
$bXx   = bool
$iXx   = int
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
						the vars of class autoformBQ

$strName	 = "";          // the form-name
$strMethod   = "POST";      // the form-method get|post
$strAction   = "";          // the action-file
$strHeadline = "";          // your Text at the top, if needed
$strFootline = "";          // your Text at the bottom, if needed
$aFields     = array();     // the field-objekt array
$iFields     = 0;           // the number of columns in your query-result
$iConnID     = 0;           // mySql-connection
$aResult;                   // the mySql-Result 2 build the form
$bFormEdit  = FALSE;        // if FALSE, the Form is used to insert
	                               // (a) new record(s) into your DB(s)
								   // if TRUE, it is used to edit and it
								   // shows the current content of your record(s)
$bShowDateTimeInput    = FALSE;    // if TRUE, a date-input-element is shown, use func showDateTimeInputt to set to true
$bShowPatternAsHint = FALSE;       // if TRUE, the format-pattern is shown as hint
$bShowPrecisionAsHint = FALSE;     // shows precision and decimals as hint
$bShowPatternAsDefault = FALSE;    // if true, the pattern is shown as input-value
$bMarkRequiredInput    = FALSE;    // shows the $strSignInputRequired ( see lang.inc )
$strCssClass = "";                 // to define a css-class use func css_class
$strEnumStyle = "radio";           // how enum-Columns are displayed
$strSetStyle  = "select";          // s.a.
$strLang = "en";                   // defines the language
$iMaxSelectSize = 5;		       // max number of items in a "sized" select-tag (only enum, set is always swhow as "sized" select)
								   // if there are more, its shown with size 1

$iSmallTextareaRows   =  3;        // varchar-columns may be shown as textarea
$iSmallTextareaCols   = 30;        // these vars define the size
$iTextareaRows        =  7;        //
$iTextareaCols        = 30;        // Textarea is used for Text/String
$iTextareaStartLen    = 50;        // This maxlen or more: Textarea is used, otherwise text-input
$iTextInputSize       = 25;        // Text-input is displayed in this size



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
						the funcs of class autoformBQ


function autoformBQ($iConnID, $result, $strAction,$bEdit= FALSE)
	// Constructor, builds the array of field-objects from your
	// query-result
	// Param : int mySql-connection-id, array query-result,
	           string "action-file" that processes the form-input,
			   bool $bEdit ( if True the first row in your result is edited)
	// return: void





function print_form()
	// prints your form


function markRequiredInput ( $bool = TRUE)
	// if you decide to mark not_null columns call this func
	// use $strSignInputRequired in autoformBQ_lang.xx.inc.php
	// to define your "sign"
	//  param : sure thing (s.a.)
	//  return: void


function showPatternAsDefault ( $bool = TRUE)
	// the column-pattern may be shown as a default-value
	// at numeric, date,datetime,time columns
	// in "new"-forms. If you decide to do so
	// call this func
	//  param : sure thing (s.a.)
	//  return: void


function showPrecisionAsHint($bool = TRUE)
	// the precision of numeric columns may be shown as a hint
	// below the tag-caption
	// param : sure thing (s.a.)
	// return: void


function showDateTimeInput($bool = TRUE)
	// mostly date,datetime,time or year -columns
	// dont appear in a form cause they are set by the NOW()-func of mySql
	// in a insert or update query
	// these fields are passed as a hidden input-tag
	// with the name: "tablename,fieldname,field-tpye,field-flag"
	// and the value: "EMPTY";
	//
	// if you need your column to be edited by the user
	// call this func to show the columns
	//
	// param : sure thing (s.a.)
	// return: void


function headline($strHeadline)
	// s.a. (but over the input-tags  :-) )


function footline($strfootline)
	// if you want to display a footline below your form
	// define the line with this func
	// param: the string, remember to escape quotes
	// return: void



function name($strName)
	// if you want to define a name for your form
	// param: the name
	// return: void


function set_style( $strType)
	// set-columns may be displayed as
	// select(the default)  or checkbox
	// param: string type ( select|checkbox )
	// return: void

function enum_style( $strType)
	// enum-columns may be displayed as
	// radio(the default)  or select
	// param: string type ( select|radio )
	// return: void


function css_class($strCssClass="")
	// if you wand to use CSS, define the class-name here
	// this class-name is used at the tags form,table,tr and td
	// param: the class-name
	// return: void

function lang($strLang)
	// some strings may be defined in a lang.inc (default "en");
	// store your settings in a file autoformBQ-lang_xx.inc.php
	// change the language with this func
	// param: the language-string ( e.g. "de")
	// return: void

function print_form_data()
	// used during development
	// prints all form-data