Class TDataSourceConfig
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 TDataSourceConfig::setConnectionClass()
attribute for a custom database connection class
that extends the TDbConnection class.
- TComponent
-
TApplicationComponent
-
TModule implements IModule
-
TDataSourceConfig
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizho[at]gmail[dot]com>
Since: 3.1
Located at Data/TDataSourceConfig.php
public
|
#
init(
Initalize the database connection properties from attributes in <database> tag. |
public
|
#
setConnectionID( string $value )
The module ID of another TDataSourceConfig. The getDbConnection DbConnection property of this configuration will equal to getDbConnection DbConnection of the given TDataSourceConfig module. |
public
string
|
|
public
|
#
getDbConnection( )
Gets the TDbConnection from another module if setConnectionID ConnectionID is supplied and valid. Otherwise, a connection of type given by setConnectionClass ConnectionClass is created. |
public
|
|
public
|
|
public
|
#
setConnectionClass( string $value )
The database connection class name to be created when |
protected
|
#
findConnectionByID( string $id )
Finds the database connection instance from the Application modules. |
getID(),
setID()
|
getApplication(),
getRequest(),
getResponse(),
getService(),
getSession(),
getUser(),
publishAsset(),
publishFilePath()
|
GLOBAL_RAISE_EVENT_LISTENER
|