- CLASS METHODS
- OBJECT METHODS
- SEE ALSO
DbFramework::PrimaryKey - Primary key class
use DbFramework::PrimaryKey; $pk = new DbFramework::Primary(\@attributes,$table,\@labels); $sql = $pk->as_sql; $html = $pk->html_select_field(\@column_names,$multiple,\@default); $html = $pk->as_html_heading; $html = $pk->as_hidden_html(\%values); $qw = $pk->as_query_string(\%values);
The DbFramework::PrimaryKey class implements primary keys for a table.
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. $table is the DbFramework::Table to which the primary key belongs. @labels is a list of column names which should be used as labels when calling html_select_field(). @labels will default to all columns in $table.
Returns a string which can be used in an SQL 'CREATE TABLE' statement to create the primary key.
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).
Returns a string for use as a column heading cell in an HTML table;
Returns a CGI query string consisting of attribute names from the primary key and their corresponding values from %values.
Returns hidden HTML form fields for each primary key attribute. The field name is pk_$attribute_name. The field value is the value in %values whose key is $attribute_name. This method is useful for tracking the previous value of a primary key when you need to update a primary key.
Paul Sharpe <email@example.com>
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.