RT 5.0.3 Documentation

RT::Handle

Go to latest version →

NAME

RT::Handle - RT's database handle

SYNOPSIS

    use RT;
    BEGIN { RT::LoadConfig() };
    use RT::Handle;

DESCRIPTION

RT::Handle is RT specific wrapper over one of DBIx::SearchBuilder::Handle classes. As RT works with different types of DBs we subclass repsective handler from DBIx::SearchBuilder. Type of the DB is defined by RT's DatabaseType config option. You must load this module only when the configs have been loaded.

METHODS

FinalizeDatabaseType

Sets RT::Handle's superclass to the correct subclass of DBIx::SearchBuilder::Handle, using the DatabaseType configuration.

Connect

Connects to RT's database using credentials and options from the RT config. Takes nothing.

BuildDSN

Build the DSN for the RT database. Doesn't take any parameters, draws all that from the config.

DSN

Returns the DSN for this handle. In order to get correct value you must build DSN first, see "BuildDSN".

This is method can be called as class method, in this case creates temporary handle object, "BuildDSN builds DSN" and returns it.

SystemDSN

Returns a DSN suitable for database creates and drops and user creates and drops.

Gets RT's DSN first (see DSN) and then change it according to requirements of a database system RT's using.

Database compatibility and integrity checks

Database maintanance

CreateDatabase $DBH

Creates a new database. This method can be used as class method.

Takes DBI handle. Many database systems require special handle to allow you to create a new database, so you have to use SystemDSN method during connection.

Fetches type and name of the DB from the config.

DropDatabase $DBH

Drops RT's database. This method can be used as class method.

Takes DBI handle as first argument. Many database systems require a special handle to allow you to drop a database, so you may have to use SystemDSN when acquiring the DBI handle.

Fetches the type and name of the database from the config.

InsertACL

InsertSchema

GetVersionFile

Takes base name of the file as argument, scans for <base name>-<version> named files and returns file name with closest version to the version of the RT DB.

InsertInitialData

Inserts system objects into RT's DB, like system user or 'nobody', internal groups and other records required. However, this method doesn't insert any real users like 'root' and you have to use InsertData or another way to do that.

Takes no arguments. Returns status and message tuple.

It's safe to call this method even if those objects already exist.

InsertData

Load some sort of data into the database, takes path to a file.

ACLEquivGroupId

Given a userid, return that user's acl equivalence group

QueryHistory

Returns the SQL query history associated with this handle. The top level array represents a lists of request. Each request is a hash with metadata about the request (such as the URL) and a list of queries. You'll probably not be using this.

AddRequestToHistory

Adds a web request to the query history. It must be a hash with keys Path (a string) and Queries (an array reference of arrays, where elements are time, sql, bind parameters, and duration).

Quote

Returns the parameter quoted by DBI. You almost certainly do not need this. Use bind parameters (?) instead. This is used only outside the scope of interacting with the database.

FillIn

Takes a SQL query and an array reference of bind parameters and fills in the query's ? parameters.

← Back to index