NAME

DbFramework::PrimaryKey - Primary key class

SYNOPSIS

use DbFramework::PrimaryKey;
$pk   = new DbFramework::Primary(\@attributes);
$sql  = $pk->as_sql;
$html = $pk->html_pk_select_field(\@column_names,$multiple,\@default);
$html = $pk->as_html_heading;
$qw   = $pk->as_query_string(\%values);

DESCRIPTION

The DbFramework::PrimaryKey class implements primary keys for a table.

SUPERCLASSES

DbFramework::Key

CLASS METHODS

new(\@attributes)

Create a new DbFramework::PrimaryKey object. @attributes is a list of DbFramework::Attribute objects from a single DbFramework::Table object which make up the key.

OBJECT METHODS

as_sql()

Returns a string which can be used in an SQL 'CREATE TABLE' statement to create the primary key.

html_select_field(\@column_names,$multiple,\@default,$name)

Returns an HTML form select field where the value consists of the values from the columns which make up the primary key and the labels consist of the corresponding values from @column_names. If @column_names is undefined the labels consist of the values from all column names. If $multiple is defined the field will allow multiple selections. @default is a list of values in the select field which should be selected by default. For fields which allow only a single selection the first value in @default will be used as the default. If $name is defined it will be used as the name of the select field, otherwise the name will consist of the attribute names of the primary key joined by ',' (comma) and the values will consist of the corresponding attribute values joined by ',' (comma).

as_html_heading()

Returns a string for use as a column heading cell in an HTML table;

as_query_string(\%values)

Returns a CGI query string consisting of attribute names from the primary key and their corresponding values from %values.

SEE ALSO

DbFramework::Key

AUTHOR

Paul Sharpe <paul@miraclefish.com>

COPYRIGHT

Copyright (c) 1997,1998,1999 Paul Sharpe. England. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.