Every repository with this icon (
Every repository with this icon (
DaoFactory
Usage
Example 1: Standard usage
This pattern allows automated creation and maintenance of Connectors with the ease of syntax of DynamicDaos
$dao = DaoFactory::create('DB.Table'); // Returns an instance of the appropriate DynamicDao
Example 2: Using DaoFactory without DynamicDao
This usage pattern allows automated creation and maintenance of Connectors with direct SQL queries.
$connector = DaoFactory::connect('DB'); // Returns an instance of the appropriate Connector $connector->query('SELECT * FROM table');
Example 3: Using DaoFactory::create without DynamicDao (deprecated)
Using create() without DynamicDao is allowed, but not recommended. It is better to use connect() as in Example 2.
$connector = DaoFactory::create('DB.Table'); $connector->query('SELECT * FROM other_table'); // See how the resource string and table name do not match?
Constants
Properties
Methods
connect
public static connect($database)
Returns a connector appropriate to the given database.
param {str} Name of database
return {bool} Success or failure
create
public static create($resource[, $type=‘select’])
Creates a connection to a data resource
param {str} daonut resource string in format DB.Table
param {str} Query type (default: ‘select’)
return {obj} Instance of a DynamicDao class
getConnectionString
public static getConnectionString($alias[, $file = ‘dsn2connector.inc.php’])
Gets the connection string for a DSN alias
Loads the DSN mapping information and returns the connection string for the given DSN alias.
param {str} DSN alias
return {str} Connection string in parse_url format
getConnector
public static getConnector($connection_string)
Gets a connector object based on a connection string
param {str} Connection string in parse_url format
return {obj} New instance of connector class
getDSN
public static getDSN($alias, $file = ‘db2dsn.inc.php’)
Gets the DSN alias for a database
Loads the database mapping information and returns the DSN alias for the given database.






