Holds DSN parsing methods, connection properties etc. Many of these can be set automatically by providing a DSN string e.g. phptype://username:pword@hostspec/database_name
Additionally custom properties for the database can be assigned into the options via dbOptions::setParam().
public __construct([$inDsn = null])
Returns a new dbOptions object
public static getInstance([$inDsn = null])
Returns a new instance of dbOptions from the supplied DSN, throws an exception if DSN can not be parsed
public parseDsn()
Parses a DSN string into parameters
The format of the supplied DSN is in its fullest form:
phptype(dbsyntax)://username:password@protocol+hostspec/database?option=8&another=true
Most variations are allowed:
phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644 phptype://username:password@hostspec/database_name phptype://username:password@hostspec phptype://username@hostspec phptype://hostspec/database phptype://hostspec phptype(dbsyntax) phptype
This function is 'borrowed' from PEAR /DB.php and ezComponents database/factory class.
public validateOptions()
Validates the object to make sure we can connect
public reset()
Resets the dbOptions object
public getParam($inParam)
Get the param
public getOptionalParams()
Returns all params that are not part of the main params
public setParam($inParam, $inValue)
Set db param value
public getError()
Returns the error message from validation
public setError($inString)
Set the error message, triggers the dbOptions to be invalid
public isValid()
Returns true if dbOptions are valid
protected setValid([$inStat = false])
Set the valid status
public getDsn()
Returns the current DSN
public setDsn($inDsn)
Set the DSN string
public getDbDsn()
Returns the database specific PDO DSN string
public setDbDsn($inDsn)
Set the PDO db DSN string
public getDbType()
Returns the current dbType
public setDbType($inType)
Set the db type
public getDbSyntax()
Returns the current dbSyntax
public setDbSyntax($inSyntax)
Set the db syntax
public getProtocol()
Return the current connection protocol
public setProtocol($inProtocol)
Set the protocol
public getHost()
Return the db host
public setHost($inHost)
Set the database host
public getPort()
Return the db port
public setPort($inPort)
Set the database port
public getSocket()
Returns the socket location
public setSocket($inSocket)
Set the socket location
public getUser()
Return the connection user
public setUser($inUser)
Set the database connection user
public getPassword()
Return the connection users password
public setPassword($inPassword)
Set the database connection password
public getDatabase()
Return default database
public setDatabase($inDatabase)
Set the default database
public areStatsEnabled()
Return if debug mode is enabled
public setStats([$inStatus = false])
Enable or disable query stats / logging
Posted by: Scorpio Documentor (Writer), in Db on 19 Nov 2009 @ 20:30
Tags: baseset, countable, db, dboptions, iteratoraggregate, traversable,
This
work is licenced under a
Creative Commons Licence.