## Class TDataSourceConfig

Description

TDataSourceConfig module class provides <module> configuration for database connections.

Example usage: mysql connection

     <modules>
         <module id="db1">
             <database ConnectionString="mysqli:host=localhost;dbname=test"
                 username="dbuser" password="dbpass" />
         </module>
     </modules>

Usage in php:

     class Home extends TPage
     {
             function onLoad($param)
             {
                 $db = $this->Application->Modules['db1']->DbConnection;
                 $command->createCommand('...'); //...
             }
     }

The properties of <connection> are those of the class TDbConnection. Set setConnectionClass attribute for a custom database connection class that extends the TDbConnection class.

- since: 3.1
- version: $Id: TDataSourceConfig.php 1596 2007-01-04 11:23:26Z wei $
- author: Wei Zhuo <weizho[at]gmail[dot]com>

Located in /Data/TDataSourceConfig.php (line 47)

    TComponent
       |
       --TApplicationComponent
          |
          --TModule
             |
             --TDataSourceConfig

Direct descendents

Class | Description
--- | ---
TActiveRecordConfig | TActiveRecordConfig module configuration class.
TSqlMapConfig | TSqlMapConfig module configuration class.

Method Summary
TDbConnection findConnectionByID (string $id)
void getConnectionClass (string 0)
string getConnectionID ()
TDbConnection getDatabase ()
TDbConnection getDbConnection ()
void init (TXmlDocument $xml)
void setConnectionClass (string $value)
void setConnectionID (string $value)
Methods
findConnectionByID (line 143)

Finds the database connection instance from the Application modules.

- return: database connection.
- access: protected
- throws: TConfigurationException when module is not of TDbConnection or TDataSourceConfig.

TDbConnection findConnectionByID (string $id)

- string $id: Database connection module ID.

getConnectionClass (line 116)

- access: public

void getConnectionClass (string 0)

- string 0: Database connection class name to be created.

getConnectionID (line 81)

- return: connection module ID.
- access: public

string getConnectionID ()
getDatabase (line 108)

Alias for getDbConnection().

- return: database connection.
- access: public

TDbConnection getDatabase ()
getDbConnection (line 92)

Gets the TDbConnection from another module if setConnectionID is supplied and valid. Otherwise, a connection of type given by setConnectionClass is created.

- return: database connection.
- access: public

TDbConnection getDbConnection ()
init (line 57)

Initalize the database connection properties from attributes in <database> tag.

- access: public

void init (TXmlDocument $xml)

- TXmlDocument $xml: xml configuration.

Redefinition of:

TModule::init()
  Initializes the module.

Redefined in descendants as:

- TActiveRecordConfig::init() : Initialize the active record manager.

setConnectionClass (line 130)

The database connection class name to be created when getDbConnection

method is called and ConnectionID is null. The ConnectionClass property must be set before calling getDbConnection if you wish to create the connection using the given class name.

- access: public
- throws: TConfigurationException when database connection is already established.

void setConnectionClass (string $value)

- string $value: Database connection class name.

setConnectionID (line 73)

The module ID of another TDataSourceConfig. The getDbConnection property of this configuration will equal to getDbConnection of the given TDataSourceConfig module.

- access: public

void setConnectionID (string $value)

- string $value: module ID.

#### Inherited Methods

Inherited From TModule

> TModule::getID()
> TModule::init()
> TModule::setID()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

Inherited From TComponent

> TComponent::addParsedObject()
> TComponent::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> TComponent::createdOnTemplate()
> TComponent::detachEventHandler()
> TComponent::evaluateExpression()
> TComponent::evaluateStatements()
> TComponent::getEventHandlers()
> TComponent::getSubProperty()
> TComponent::hasEvent()
> TComponent::hasEventHandler()
> TComponent::hasProperty()
> TComponent::raiseEvent()
> TComponent::setSubProperty()
> TComponent::__get()
> TComponent::__set()

Documentation generated on Sun, 14 Jan 2007 21:42:05 -0500 by phpDocumentor 1.3.0RC4