|
|
|
|
|
|
dbInfo |
dbInfo (
string |
$db |
string |
$table |
string |
$type = null |
) |
Arguments:
Name |
Description |
$db |
The name of the database where you want to connect to |
$table |
The name of the table where the values should loaded from and stored in. |
$type |
The type of database you are connecting to. The default is set in the configuration file with the var FH_DEFAULT_DB_TYPE. |
Description:
This function sets the database info to make a new connection to a database. After setting this data you have to connect to
the database using the method dbConnect();
Note: You can only use these functions if you make use of the dbFormHandler class! So, include class.dbFormHandler.php and create a new FormHandler object with the constructor dbFormHandler().
Note: If you want to use an already opened connection, please use setConnectionResource().
Example
<?php
// include the class
include('FH3/class.dbFormHandler.php');
// create new formhandler object
$form = new dbFormHandler();
// Set the database info and connect!
$form->dbInfo( "myDB", "myTable" );
$form->dbConnect( "localhost", "username", "password" );
// some fields + button
$form->textField("Name", "name", FH_STRING, 20, 50);
$form->textField("Age", "age", FH_INTEGER, 3, 3);
$form->selectField("Gender", "gender", array('M', 'F'), null, false);
$form->submitButton("Save");
// data handling
// MAKE SURE YOU USE ONSAVED!
$form->onSaved("doRun");
// display the page
$form->flush();
// the data handler
function doRun( $id, $data )
{
echo
"Hello ". $data['name'] ."\n".
"Your data is saved!\n";
}
?>
|
See also: dbFormHandler | dbConnect | SetConnectionResource
Latest change: 05 March 10 / 08:56
Comments
|
|
|
|