Class DBHandler

Description

A Database Handler. The DBHandler is to be loaded at the beginning program executution with configuration settings for the database type, name, server, user, and password.

  • version: $Id: DBHandler.class.php,v 1.27 2007/09/14 13:57:06 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/DBHandler/DBHandler.class.php (line 74)


	
			
Variable Summary
array $_databases
Method Summary
DBHandler DBHandler ()
mixed addDatabase (Database $database)
void assignConfiguration (object Properties $configuration)
void assignOsidContext (mixed $context, object OsidContext $context )
void beginTransaction (mixed $dbIndex)
void commitTransaction (mixed $dbIndex)
boolean connect (integer $dbIndex)
mixed createDatabase (string $dbType, string $dbHost, string $dbName, string $dbUser, string $dbPass)
boolean disconnect (integer $dbIndex)
ref fromDBDate (mixed $value, integer $dbIndex)
string generateSQL (Query $query, int $dbIndex)
integer getDatabaseType (optional $dbIndex)
object OsidContext getOsidContext ()
string getStringName (mixed $dbIndex)
array getTableList (optional $index)
boolean isConnected (mixed $dbIndex)
boolean pConnect (integer $dbIndex)
object QueryResultInterface query (Query $query, integer $dbIndex)
object QueInterface queryQueue (Queue $queue, integer $dbIndex)
void rollbackTransaction (mixed $dbIndex)
boolean supportsTransactions (mixed $dbIndex)
mixed toDBDate (DateAndTime $dateAndTime, integer $dbIndex)
void _validateDBIndex (integer $dbIndex)
Variables
array $_databases (line 82)

An array of all databases.

An array of all databases.

  • var: An array of all databases.
  • access: private
Methods
Constructor DBHandler (line 90)

Constructor.

  • access: public
DBHandler DBHandler ()
addDatabase (line 152)

Adds the specified Database object to the list of databases.

  • return: The index of the new database, if it was created successfully; False, otherwise.
  • access: public
mixed addDatabase (Database $database)
  • ref $database: object database
assignConfiguration (line 114)

Assign the configuration of this Manager. Valid configuration options are as

follows: database_index integer database_name string

  • access: public
  • throws: object OsidException An exception with one of the following messages defined in org.osid.OsidException: OPERATION_FAILED, PERMISSION_DENIED, CONFIGURATION_ERROR, UNIMPLEMENTED, NULL_ARGUMENT
void assignConfiguration (object Properties $configuration)
  • object Properties $configuration: (original type: java.util.Properties)
assignOsidContext (line 142)

Assign the context of this OsidManager.

  • access: public
  • throws: object OsidException An exception with one of the following messages defined in org.osid.OsidException: NULL_ARGUMENT
void assignOsidContext (mixed $context, object OsidContext $context )
  • object OsidContext $context
beginTransaction (line 487)

Begin a transaction.

  • since: 3/9/05
  • access: public
void beginTransaction (mixed $dbIndex)
commitTransaction (line 503)

Commit a transaction. This will roll-back changes if errors occured in the transaction block.

  • since: 3/9/05
  • access: public
void commitTransaction (mixed $dbIndex)
connect (line 352)

Connect to the database.

  • return: True, if successful; False, otherwise.
  • access: public
boolean connect (integer $dbIndex)
  • integer $dbIndex: The index of the database with which to connect. Default is 0, the database created on handler instantiation.
createDatabase (line 173)

*Deprecated* Creates a new database connection.

  • return: The index of the new database, if it was created successfully; False, otherwise.
  • access: public
  • deprecated: July 20, 2003 - Use addDatabase instead.
mixed createDatabase (string $dbType, string $dbHost, string $dbName, string $dbUser, string $dbPass)
  • string $dbType: The type of database: MYSQL, POSTGRES, ORACLE, OKI, etc.
  • string $dbHost: The hostname for the database, i.e. myserver.mydomain.edu.
  • string $dbName: The name of the database.
  • string $dbUser: The username with which to connect to the database.
  • string $dbPass: The password for $_dbUser with which to connect to the database.
disconnect (line 392)

disconnect from the database.

  • return: True, if successful; False, otherwise.
  • access: public
boolean disconnect (integer $dbIndex)
  • integer $dbIndex: The index of the database with which to disconnect. Default is 0, the database created on handler instantiation.
fromDBDate (line 456)

Converts a database datetime/timestamp/time value (that has been fetched from the db) to a DateAndTime object.

  • return: object The DateAndTime object.
  • access: public
ref fromDBDate (mixed $value, integer $dbIndex)
  • mixed $value: A database datetime/timestamp/time value (that has been fetched from the db).
  • integer $dbIndex: dbIndex The index of the database to use (0 by default).
generateSQL (line 555)

Generate the SQL string for the specified Query and Database

  • since: 11/14/06
  • access: public
string generateSQL (Query $query, int $dbIndex)
  • object $query
  • int $dbIndex
getDatabaseType (line 234)

Answer the type of the database. Will be one of the constants defined above: MYSQL, POSTGRESQL, ORACLE, or SQLSERVER

  • access: public
  • since: 9/11/07
integer getDatabaseType (optional $dbIndex)
  • optional $dbIndex: integer $dbIndex Default is 0.
getOsidContext (line 127)

Return context of this OsidManager.

  • access: public
  • throws: object OsidException
object OsidContext getOsidContext ()
getStringName (line 296)

Returns the short string name of the database index passed.

  • access: public
string getStringName (mixed $dbIndex)
getTableList (line 219)

Returns a list of the tables that exist in the database referenced by $index.

  • access: public
array getTableList (optional $index)
  • optional $index: integer $index
getTotalNumberOfFailedQueries (line 338)

Gets the total number of queries that have failed so far.

Gets the total number of queries that have failed so far.

  • return: The number of queries that have failed so far.
  • access: public
integer getTotalNumberOfFailedQueries ()
getTotalNumberOfQueries (line 308)

Gets the total number of queries that have been run so far.

Gets the total number of queries that have been run so far.

  • return: The number of queries that have run so far.
  • access: public
integer getTotalNumberOfQueries ()
getTotalNumberOfSuccessfulQueries (line 324)

Gets the total number of queries that have been run successfully so far.

Gets the total number of queries that have been run successfully so far.

  • return: The number of queries that have run successfully so far.
  • access: public
integer getTotalNumberOfSuccessfulQueries ()
isConnected (line 413)

Indicates whether there is an open connection to the database.

Indicates whether there is an open connection to the database.

  • return: True, if there is an open connection to the database; False, otherwise.
  • access: public
boolean isConnected (mixed $dbIndex)
pConnect (line 372)

Persistantly connect to the database.

  • return: True, if successful; False, otherwise.
  • access: public
boolean pConnect (integer $dbIndex)
  • integer $dbIndex: The index of the database with which to pconnect. Default is 0, the database created on handler instantiation.
query (line 260)

Run a database query based on the Query object and return a QueryResult object.

  • return: Returns a QueryResult object that impliments QueryResultInterface and corresponds to the DB configuration.
  • access: public
object QueryResultInterface query (Query $query, integer $dbIndex)
  • integer $dbIndex: The index of the database on which to run the query. Default is 0, the database created on handler instantiation.
  • object Query $query: A query object which holds the query to run.
queryQueue (line 278)

Run a database query for each Query in the Queue and return a Queue of QueryResults.

  • return: Returns a Queue of QueryResults.
  • access: public
object QueInterface queryQueue (Queue $queue, integer $dbIndex)
  • integer $dbIndex: The index of the database on which to run the query. Default is 0, the database created on handler instantiation.
  • object QueueInterface $queue: A queue object which holds the queries to run.
rollbackTransaction (line 518)

Roll-back a transaction manually instead of committing

  • since: 3/9/05
  • access: public
void rollbackTransaction (mixed $dbIndex)
supportsTransactions (line 472)

Return TRUE if this database supports transactions.

  • since: 3/9/05
  • access: public
boolean supportsTransactions (mixed $dbIndex)
toDBDate (line 435)

Converts a DateAndTime object to a proper datetime/timestamp/time representation for the specified database object. $dateAndTime must implement asDateAndTime().

  • return: A proper datetime/timestamp/time representation for this Database.
  • access: public
mixed toDBDate (DateAndTime $dateAndTime, integer $dbIndex)
  • ref $dateAndTime: object DateAndTime The DateAndTime object to convert.
  • integer $dbIndex: dbIndex The index of the database to use (0 by default).
_validateDBIndex (line 534)

Private method for validating the dbIndex passed.

  • since: 3/9/05
  • access: private
void _validateDBIndex (integer $dbIndex)
  • integer $dbIndex

Documentation generated on Wed, 19 Sep 2007 10:22:38 -0400 by phpDocumentor 1.3.0RC3