PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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
Extended by TApplicationComponent
Extended by TModule implements IModule
Extended by TDataSourceConfig

Direct known subclasses

TActiveRecordConfig, TSqlMapConfig
Package: System\Data
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
Methods summary
public
# init( TXmlDocument $xml )

Initalize the database connection properties from attributes in <database> tag.

Initalize the database connection properties from attributes in <database> tag.

Parameters

$xml
TXmlDocument
xml configuration.

Overrides

TModule::init()
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.

The module ID of another TDataSourceConfig. The getDbConnection DbConnection property of this configuration will equal to getDbConnection DbConnection of the given TDataSourceConfig module.

Parameters

$value
string
module ID.
public string
# getConnectionID( )

Returns

string
connection module ID.
public TDbConnection
# 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.

Gets the TDbConnection from another module if setConnectionID ConnectionID is supplied and valid. Otherwise, a connection of type given by setConnectionClass ConnectionClass is created.

Returns

TDbConnection
database connection.
public TDbConnection
# getDatabase( )

Alias for getDbConnection().

Alias for getDbConnection().

Returns

TDbConnection
database connection.
public
# getConnectionClass( )
public
# setConnectionClass( string $value )

The database connection class name to be created when TDataSourceConfig::getDbConnection() method is called and setConnectionID ConnectionID is null. The setConnectionClass ConnectionClass property must be set before calling TDataSourceConfig::getDbConnection() if you wish to create the connection using the given class name.

The database connection class name to be created when TDataSourceConfig::getDbConnection() method is called and setConnectionID ConnectionID is null. The setConnectionClass ConnectionClass property must be set before calling TDataSourceConfig::getDbConnection() if you wish to create the connection using the given class name.

Parameters

$value
string
Database connection class name.

Throws

TConfigurationException
when database connection is already established.
protected TDbConnection
# findConnectionByID( string $id )

Finds the database connection instance from the Application modules.

Finds the database connection instance from the Application modules.

Parameters

$id
string
Database connection module ID.

Returns

TDbConnection
database connection.

Throws

TConfigurationException
when module is not of TDbConnection or TDataSourceConfig.
Methods inherited from TModule
getID(), setID()
Methods inherited from TApplicationComponent
getApplication(), getRequest(), getResponse(), getService(), getSession(), getUser(), publishAsset(), publishFilePath()
Methods inherited from TComponent
__call(), __construct(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO