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.
Located in /Data/TDataSourceConfig.php (line 49)
TComponent | --TApplicationComponent | --TModule | --TDataSourceConfig
Class | Description |
---|---|
TActiveRecordConfig | TActiveRecordConfig module configuration class. |
TSqlMapConfig | TSqlMapConfig module configuration class. |
Finds the database connection instance from the Application modules.
Gets the TDbConnection from another module if setConnectionID is supplied and valid. Otherwise, a connection of type given by setConnectionClass is created.
Initalize the database connection properties from attributes in <database> tag.
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.
The module ID of another TDataSourceConfig. The getDbConnection property of this configuration will equal to getDbConnection of the given TDataSourceConfig module.
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 Mon, 21 Apr 2008 11:34:40 -0400 by phpDocumentor 1.3.0RC4