- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

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:
TDataSourceConfig
TDbColumnCaseMode
TDbCommand
TDbConnection
TDbDataReader
TDbNullConversionMode
TDbTransaction

Keyword

# Class TDataSourceConfig

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

#### Direct Known Sub-classes:

TActiveRecordConfig , TSqlMapConfig

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;
                 $db->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
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 | getConnectionID ()
TDbConnection | getDatabase () Alias for getDbConnection().
TDbConnection | getDbConnection () 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 | $id | Database connection module ID.
Output
TDbConnection | database connection.
Exception
throws | TConfigurationException when module is not of TDbConnection or TDataSourceConfig.

## getConnectionClass

public void getConnectionClass | (string 0 )

Input
string | 0 | Database 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 | $xml | xml 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 | $value | Database connection class name.
Output
Exception
throws | TConfigurationException 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 | $value | module ID.
Output
Exception