|
|
|
|
|
|
dbConnect |
dbConnect (
string |
$host = null, |
string |
$username = "", |
string |
$password = "" |
) |
Arguments:
Name |
Description |
$host |
The host where the database is located. This could also be the server name for some types of databases. When no host is given, the host saved with the var FH_DEFAULT_DB_HOST from the configuration file is used. |
$username |
The username which should be used loggin in into the database. |
$password |
The password which should be used loggin in into the database. |
Description:
Create a new connection to the database after setting the database data with the function dbInfo().
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! (Create a new connection)
$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 | dbInfo | SetConnectionResource
Latest change: 27 June 08 / 09:27
Comments
|
|
|
|