Class \Prado\Data\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
Class hierarchy
- \Prado\Data\TDataSourceConfig
- \Prado\TModule implements IModule
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.1
public
|
|
public
|
|
public
|
|
public
|
getDbConnection() : TDbConnection
Gets the TDbConnection from another module if {@see setConnectionID ConnectionID}
is supplied and valid. Otherwise, a connection of type given by
{@see setConnectionClass ConnectionClass} is created.
|
public
|
init(TXmlDocument $config) : mixed
Initalize the database connection properties from attributes in <database> tag.
|
public
|
setConnectionClass(string $value) : mixed
The database connection class name to be created when {@see getDbConnection}
method is called <b>and</b> {@see setConnectionID ConnectionID} is null. The
{@see setConnectionClass ConnectionClass} property must be set before
calling {@see getDbConnection} if you wish to create the connection using the
given class name.
|
public
|
setConnectionID(string $value) : mixed
The module ID of another TDataSourceConfig. The {@see getDbConnection DbConnection}
property of this configuration will equal to {@see getDbConnection DbConnection}
of the given TDataSourceConfig module.
|
protected
|
findConnectionByID(string $id) : TDbConnection
Finds the database connection instance from the Application modules.
|
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |