Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TDataSourceConfig

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

Direct Known Sub-classes:

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

Example usage: mysql connection

  1. <modules>
  2. <module id="db1">
  3. <database ConnectionString="mysqli:host=localhost;dbname=test"
  4. username="dbuser" password="dbpass" />
  5. </module>
  6. </modules>

Usage in php:

  1. class Home extends TPage
  2. {
  3. function onLoad($param)
  4. {
  5. $db = $this->Application->Modules['db1']->DbConnection;
  6. $db->createCommand('...'); //...
  7. }
  8. }

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
Author: Wei Zhuo <weizho[at]gmail[dot]com>

Method Summary
protected  TDbConnection
findConnectionByID ( string $id)
Finds the database connection instance from the Application modules.
void
getConnectionClass ( string 0)
string
TDbConnection
Alias for getDbConnection().
TDbConnection
Gets the TDbConnection from another module if setConnectionID is supplied and valid. Otherwise, a connection of type given by setConnectionClass is created.
void
init ( TXmlDocument $xml)
Initalize the database connection properties from attributes in <database> tag.
void
setConnectionClass ( string $value)
The database connection class name to be created when getDbConnection
void
setConnectionID ( string $value)
The module ID of another TDataSourceConfig. The getDbConnection property of this configuration will equal to getDbConnection of the given TDataSourceConfig module.
Methods Inherited From TModule
TModule::getID(), TModule::init(), TModule::setID()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods 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()

Method Details

findConnectionByID

protected TDbConnection findConnectionByID (string $id )

Finds the database connection instance from the Application modules.

Input
string$idDatabase connection module ID.
Output
TDbConnection database connection.
Exception
throwsTConfigurationException when module is not of TDbConnection or TDataSourceConfig.

getConnectionClass

public void getConnectionClass (string 0 )

Input
string0Database connection class name to be created.
Output
Exception

getConnectionID

public string getConnectionID ()

Output
string connection module ID.
Exception

getDatabase

public TDbConnection getDatabase ()

Alias for getDbConnection().

Output
TDbConnection database connection.
Exception

getDbConnection

public TDbConnection getDbConnection ()

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

Output
TDbConnection database connection.
Exception

init

public void init (TXmlDocument $xml )

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

Input
TXmlDocument$xmlxml configuration.
Output
Exception

setConnectionClass

public void setConnectionClass (string $value )

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.

Input
string$valueDatabase connection class name.
Output
Exception
throwsTConfigurationException when database connection is already established.

setConnectionID

public void setConnectionID (string $value )

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

Input
string$valuemodule ID.
Output
Exception