NAME

WeBWorK::DB::Schema - schema superclass (to hold documentation)

SYNOPSIS

FIXME: write synopsis

DESCRIPTION

FIXME: write description

Record Identifiers and Keys

Several of the tables used in the WeBWorK database have records that are identified by the values of a set of fields, rather than by the value of a single field. Because of this, when identifying a record (in calls to the list, exists, get, and delete methods), one must specify a list of values rather than a single value. This is represented in the documentation for these methods by the expression @keyparts. The values in @keyparts correspond to the fields returned by the KEYFIELDS method of the table's record class. If an element of @keyparts is undefined, then the corresponding field is not used in the match. Some methods require all elements of @keyparts to be defined. This is noted below.

A "record key", as in the list method, is a reference to a list containing values which correspond to the the fields returned by the KEYFIELDS method of the table's record class.

CONSTRUCTOR

new($db, $driver, $table, $record, $params, $engine)

Creates a schema interface for $table, using the driver interface provided by $driver and using the record class named in $record. If the $driver does not support the driver style needed by the schema, an exception is thrown. $params contains extra information needed by the schema and is schema dependent. $db is provided so that schemas can query other schemas.

TABLE ACCESS METHODS

count(@keyparts)

Returns the number of records matching @keyparts is found in the table.

list(@keyparts)

Returns a list containing the key of each record in the table that matches the values in @keyparts. Elements of @keyparts may be undefined.

exists(@keyparts)

Returns a boolean value representing whether one or more records that match the values in @keyparts exist in the table. Elements of @keyparts may be undefined.

add($Record)

Attempts to add $Record to the table. $Record must be an instance of the table's record class. Returns true on success and false on failure (for example, if the database couldn't be contacted). If a record with the same key exists, an exception is thrown.

get(@keyparts)

Attempts to retrieve the record matching @keyparts from the table. Returns an instance of the table's record class if there is a match. Returns undef if no record matches. All elements of @keyparts must be defined.

gets(@keypartsRefs)

Returns a list of records matching the keyparts refered to in each element of @keypartsRef. Each element of the returned list will contain either a record object (if there was a match) or the value undef (if there was no match). All elements of @keyparts must be defined.

put($Record)

Attempts to replace the record in the table that matches the key of $Record. Returns true on success and false on failure (for example, if the database couldn't be contacted). If no such record exists, an exception is thrown.

delete(@keyparts)

Attempts to delete the record or records in the table that match @keyparts. Returns true if the record(s) was successfully deleted or did not exist, and false if deletion failed. Elements of @keyparts may be undefined.