Class SGL_DB

Description

Class for handling DB resources.

Located in /SGL/DB.php (line 51)


	
			
Method Summary
 static mixed getDsn ([int $type = SGL_DSN_ARRAY], [ $excludeDbName = false])
 static void setConnection ([string $dsn = null])
 static mixed &singleton ([string $dsn = null])
 array getPagedData ( &$db, string $query, [array $pager_options = array()], [boolean $disabled = false], [int $fetchMode = DB_FETCHMODE_ASSOC], [mixed $dbparams = array()], object $db)
 string rewriteCountQuery (string $sql)
 void _getDsnAsArray ( $conf, [ $excludeDbName = false])
 void _getDsnAsString ( $conf, [ $excludeDbName = false])
Methods
static getDsn (line 115)

Returns the default dsn specified in the global config.

  • return: a string or array contained the data source name
  • access: public
mixed getDsn ([int $type = SGL_DSN_ARRAY], [ $excludeDbName = false])
  • int $type: a constant that specifies the return type, ie, array or string
  • $excludeDbName
static setConnection (line 210)

Sets the DB_DataObject DB resource to be the same as the sgl DB singleton. You can use this for sharing connections between PEAR::DataObjects and SGL_DB.

This enables you to use DataObjects and SGL_DB in the same transaction.

example usage: $oUser = DB_DataObject::factory($this->conf['table']['user']); SGL_DB::setConnection(); $dbh->autocommit(); ... do some transactional DO and SGL_DB stuff $dbh->commit();

  • access: public
void setConnection ([string $dsn = null])
  • string $dsn: Supplied database resource name
static singleton (line 67)

Returns a singleton reference to the DB resource.

example usage: $dbh = & SGL_DB::singleton(); warning: in order to work correctly, DB handle singleton must be instantiated statically and by reference

  • return: reference to DB resource or PEAR error on failure to connect
  • access: public
mixed &singleton ([string $dsn = null])
  • string $dsn: the datasource details if supplied: see DB::parseDSN() for format
getPagedData (line 252)
  • return: with links and paged data
array getPagedData ( &$db, string $query, [array $pager_options = array()], [boolean $disabled = false], [int $fetchMode = DB_FETCHMODE_ASSOC], [mixed $dbparams = array()], object $db)
  • object $db: PEAR::DB instance
  • string $query: db query
  • array $pager_options: PEAR::Pager options
  • boolean $disabled: Disable pagination (get all results)
  • int $fetchMode: fetchmode to use
  • mixed $dbparams: array, string or numeric data passed to DB execute
  • &$db
rewriteCountQuery (line 232)

Helper method - Rewrite the query into a "SELECT COUNT(*)" query.

  • return: rewritten query OR false if the query can't be rewritten
  • access: private
string rewriteCountQuery (string $sql)
  • string $sql: query
_getDsnAsArray (line 146)
void _getDsnAsArray ( $conf, [ $excludeDbName = false])
  • $conf
  • $excludeDbName
_getDsnAsString (line 163)
void _getDsnAsString ( $conf, [ $excludeDbName = false])
  • $conf
  • $excludeDbName

Documentation generated on Tue, 23 Feb 2010 18:14:29 +0000 by phpDocumentor 1.4.3