DbFramework::ForeignKey - Foreign Key class


DbFramework documentation  | view source Contained in the DbFramework distribution.

Index


NAME

Top

DbFramework::ForeignKey - Foreign Key class

SYNOPSIS

Top

  use DbFramework::ForeignKey;
  $fk   = new DbFramework::ForeignKey($name,\@attributes,$primary);
  $pk   = $fk->references($primary);
  $sql  = $fk->as_sql;
  $html = $fk->as_html_form_field(\%values);
  $s    = $fk->sql_where;

DESCRIPTION

Top

The DbFramework::ForeignKey class implements foreign keys for a table.

SUPERCLASSES

Top

DbFramework::Key

CLASS METHODS

Top

new($name,\@attributes,$primary)

Returns a new DbFramework::ForeignKey object.

$name is the name of the foreign key. @attributes is a list of DbFramework::Attribute objects from a single DbFramework::Table object which make up the key. $primary is the DbFramework::Primary object which the foreign key references.

OBJECT METHODS

Top

references($primary)

$primary should be a DbFramework::PrimaryKey object. If supplied it sets the primary key referenced by this foreign key. Returns the DbFramework::PrimaryKey object referenced by this foreign key.

as_html_form_field(\%values)

Returns an HTML selection box containing values and labels from the primary key columns in the related table. %values is a hash whose keys are the attribute names of the foreign key and whose values indicate the item in the selection box which should be selected by default. See html_select_field() in DbFramework::PrimaryKey.

sql_where()

Returns a string containing SQL 'WHERE' condition(s) to join the foreign key against the primary key of the related table.

SEE ALSO

Top

DbFramework::Key, DbFramework::PrimaryKey and DbFramework::Catalog.

AUTHOR

Top

Paul Sharpe <paul@miraclefish.com>

COPYRIGHT

Top


DbFramework documentation  | view source Contained in the DbFramework distribution.