Constructor.
DBHandler
DBHandler
()
Adds the specified Database object to the list of databases.
mixed
addDatabase
(Database $database)
-
ref
$database: object database
Assign the configuration of this Manager. Valid configuration options are as
follows: database_index integer database_name string
void
assignConfiguration
(object Properties $configuration)
-
object Properties
$configuration: (original type: java.util.Properties)
Assign the context of this OsidManager.
void
assignOsidContext
(mixed $context, object OsidContext $context
)
-
object OsidContext
$context
Begin a transaction.
void
beginTransaction
(mixed $dbIndex)
Commit a transaction. This will roll-back changes if errors occured in the transaction block.
void
commitTransaction
(mixed $dbIndex)
Connect to the database.
boolean
connect
(integer $dbIndex)
-
integer
$dbIndex: The index of the database with which to connect. Default is 0, the database created on handler instantiation.
*Deprecated* Creates a new database connection.
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 from the database.
boolean
disconnect
(integer $dbIndex)
-
integer
$dbIndex: The index of the database with which to disconnect. Default is 0, the database created on handler instantiation.
Converts a database datetime/timestamp/time value (that has been fetched from the db) to a DateAndTime object.
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).
Generate the SQL string for the specified Query and Database
string
generateSQL
(Query $query, int $dbIndex)
-
object
$query
-
int
$dbIndex
Answer the type of the database. Will be one of the constants defined above: MYSQL, POSTGRESQL, ORACLE, or SQLSERVER
integer
getDatabaseType
(optional $dbIndex)
-
optional
$dbIndex: integer $dbIndex Default is 0.
Return context of this OsidManager.
object OsidContext
getOsidContext
()
Returns the short string name of the database index passed.
string
getStringName
(mixed $dbIndex)
Returns a list of the tables that exist in the database referenced by $index.
array
getTableList
(optional $index)
-
optional
$index: integer $index
Gets the total number of queries that have failed so far.
Gets the total number of queries that have failed so far.
integer
getTotalNumberOfFailedQueries
()
Gets the total number of queries that have been run so far.
Gets the total number of queries that have been run so far.
integer
getTotalNumberOfQueries
()
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.
integer
getTotalNumberOfSuccessfulQueries
()
Indicates whether there is an open connection to the database.
Indicates whether there is an open connection to the database.
boolean
isConnected
(mixed $dbIndex)
Persistantly connect to the database.
boolean
pConnect
(integer $dbIndex)
-
integer
$dbIndex: The index of the database with which to pconnect. Default is 0, the database created on handler instantiation.
Run a database query based on the Query object and return a QueryResult object.
-
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.
Run a database query for each Query in the Queue and return a Queue of QueryResults.
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.
Roll-back a transaction manually instead of committing
void
rollbackTransaction
(mixed $dbIndex)
Return TRUE if this database supports transactions.
boolean
supportsTransactions
(mixed $dbIndex)
Converts a DateAndTime object to a proper datetime/timestamp/time representation for the specified database object. $dateAndTime must implement asDateAndTime().
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).
Private method for validating the dbIndex passed.
void
_validateDBIndex
(integer $dbIndex)