<?php
/**
* Online web application builder class set
*
* @package OWAB
*/
/**
* Class DBConn
*
* Database connection class
* Uses AdoDB database layer, which enables to use almost anykind of database
* on backround. ADOdb can be downloaded from: http://php.weblogs.com/adodb
*
* This class must be setted properly to get PhpDtObject to work correctly. Set at least
* the followinf field variables: driver, server, username, password and database
*
* @package OWAB
* @author Marko Manninen <hide@address.com>
* @copyright Copyright © 2004, Marko Manninen
* @date 9.6. -2004
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @version 0.01
*/
class DBConn
{
/**
* ADOdb Connection link
* @access private
* @var object ADONewConnection
*/
var $_adodb;
/**#@+
* Server configuration variable
* @access public
* @var string
*/
var $driver = "mysql";
var $server = "localhost";
var $port = "";
var $socket = "";
var $username = "root";
var $password = "";
var $db = "test";
/**#@-*/
/**
* Target table from which PhpDtObject gets all the data,
* rows and metainformation
*
* @access private
* @var string
*/
var $_target_table;
/**
* Tables are fetched automatic from the selected database. Target table name is checked against
* all available tables.
* @var array
*/
var $_tables = array();
/**
* Constructor DBConn
*/
function DBConn( $table )
{
$this->_target_table = $table;
}// END OF CONSTRUCTOR
/**
* Connect
*/
function connect()
{
$db = ADONewConnection( $this->driver );
if ( $db->Connect( $this->server . $port, $this->username, $this->password, $this->db ) )
{
$this->_tables = $db->MetaTables();
$this->_adodb = $db;
//
if( in_array( $this->_target_table, $this->_tables ) )
return true;
else
{
trigger_error( "Target table ($this->_target_table) was not found from the database.", E_USER_WARNING );
return false;
}
}
else
{
trigger_error( "Could not connect to database server. Application aborted!", E_USER_WARNING );
return false;
}
}// END OF METHOD connect
/**
* Get ADOdb connection link
*/
function getLink()
{
return $this->_adodb;
}// END OF METHOD getLink
/**
* Get tables
*/
function getTables()
{
return $this->_tables;
}// END OF METHOD getTables
/**
* Get target table
*/
function getTable()
{
return $this->_target_table;
}// END OF METHOD getTable
}// END OF CLASS
?>