NAME
DbFramework::Attribute - Attribute class
SYNOPSIS
use DbFramework::Attribute;
my $a = new DbFramework::Attribute($name,$default_value,$is_optional,$data_type);
$name = $a->name($name);
$value = $a->default_value($value);
$opt = $a->is_optional($boolean);
$type = $a->references($data_type);
$bgc = $a->bgcolor($bgcolor);
$sql = $a->as_sql;
$s = $a->as_string;
$html = $a->as_html_form_field($value,$type);
$html = $a->as_html_heading($bgcolor);
DESCRIPTION
A DbFramework::Attribute object represents an attribute (column) in a table (entity).
SUPERCLASSES
DbFramework::Util
CLASS METHODS
new($name,$default_value,$is_optional,$data_type)
Create a new DbFramework::Attribute object. $name is the name of the attribute. $default_value is the default value for the attribute. $is_optional should be set to true if the attribute is optional or false. $data_type is a DbFramework::DataType object.
name($name)
If $name is supplied sets the attribute name. Returns the attribute name.
default_value($value)
If $value is supplied sets the default value for the attribute. $value should be compatible with the the data type set by references(). Returns the default value for the attribute.
is_optional($boolean)
If $boolean is supplied sets the optionality of the attribute (i.e. whether it can contain NULLs.) $boolean should evaluate to true or false. Returns the optionality of the attribute.
references($data_type)
If $data_type is supplied sets the data type of the attribute. $data_type is an ANSII data type object i.e. DbFramework::DataType::ANSII or a driver-specific object e.g. DbFramework::DataType::Mysql. Returns the data type object.
bgcolor($bgcolor)
If $color is supplied sets the background colour for HTML table headings returned by as_html_heading(). Returns the current background colour.
as_sql($dbh)
Returns a string which can be used to create a column in an SQL 'CREATE TABLE' statement. $dbh is a DBI handle.
as_html_form_field($value,$type)
Returns an HTML form field representation of the attribute. The HTML field type produced depends on the name of object returned by data_type(). This can be overidden by setting $type. $value is the default value to be entered in the generated field.
as_string()
Return attribute details as a text string.
as_html_heading($bgcolor)
Returns a string for use as a column heading cell in an HTML table. $bgcolor is the background colour to use for the heading.
SEE ALSO
DbFramework::DataType::ANSII and DbFramework::DataType::Mysql.
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.