Class TDataSourceConfig
Direct Known Sub-classes:
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.
Method Summary |
protected
TDbConnection
|
Finds the database connection instance from the Application modules.
|
void
|
|
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
|
Initalize the database connection properties from attributes in <database> tag.
|
void
|
The database connection class name to be created when getDbConnection
|
void
|
The module ID of another TDataSourceConfig. The getDbConnection property of this configuration will equal to getDbConnection of the given TDataSourceConfig module.
|
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
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
Alias for getDbConnection().
|
getDbConnection
Gets the TDbConnection from another module if setConnectionID is supplied and valid. Otherwise, a connection of type given by setConnectionClass is created.
|
init
Initalize the database connection properties from attributes in <database> tag.
|
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 |
|
|