NAME

DbFramework::Key - Key class

SYNOPSIS

  use DbFramework::Key;
  $k     = new DbFramework::Key($name,\@attributes);
  $name  = $k->name($name);
  @a     = @{$k->incorporates_l(\@attributes)};
  @names = $k->attribute_names;
  $sql   = $k->as_sql;
  $table = $k->belongs_to($table);
  $html  = $k->as_html_heading;

DESCRIPTION

The DbFramework::Key class implements keys (indexes) for a table.

SUPERCLASSES

DbFramework::Util

CLASS METHODS

new($name,\@attributes)

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

OBJECT METHODS

A key incorporates 0 or more attributes. These attributes can be accessed using the attribute INCORPORATES_L. See "AUTOLOAD()" in DbFramework::Util for the accessor methods for this attribute.

name($name)

If $name is supplied sets the data model name. Returns the data model name.

belongs_to($table)

$table is a DbFramework::Table object. If supplied sets the table to which this key refers to $table. Returns a DbFramework::Table.

bgcolor($bgcolor)

If $color is supplied sets the background colour for HTML table cells. Returns the current background colour.

attribute_names()

Returns a list of the names of the attributes which make up the key.

as_sql()

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

as_html_heading()

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

SEE ALSO

DbFramework::ForeignKey, DbFramework::PrimaryKey and DbFramework::Catalog.

AUTHOR

Paul Sharpe <paul@miraclefish.com>

COPYRIGHT

Copyright (c) 1997,1998 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.