| Class-DBI-Lite documentation | Contained in the Class-DBI-Lite distribution. |
Class::DBI::Lite::ColumnInfo - Extended meta-information about database table fields.
foreach my $field ( app::artist->columns )
{
}# end foreach()
Sometimes database table field information needs to be available during runtime.
This class provides a simple interface to query a specific database field.
Returns the name of the column.
Returns the data type of the column - varchar, int, etc.
Returns the size of the field.
True or false.
Returns the default value of the field, if any.
Returns true if the field is a primary key field. False otherwise.
Returns either undef, primary_key or unique.
ONLY if the column is an enum data type, this property will return an arraref
of the possible enum values.
It's possible that some bugs have found their way into this release.
John Drago <jdrago_999@yahoo.com>
Copyright 2008 John Drago <jdrago_999@yahoo.com>, All Rights Reserved.
This software is Free software and may be used and redistributed under the same terms as perl itself.
| Class-DBI-Lite documentation | Contained in the Class-DBI-Lite distribution. |
package Class::DBI::Lite::ColumnInfo; use strict; use warnings 'all'; #============================================================================== sub new { my ($class, %args) = @_; my @required = qw( name type length is_nullable default_value is_pk key ); foreach( @required ) { die "Required parameter '$_' was not provided" unless exists($args{$_}); }# end foreach() return bless \%args, $class; }# end new() sub null { $_[0]->{is_nullable} } sub default { $_[0]->{default_value} } sub enum_values { shift->{enum_values} } #============================================================================== sub AUTOLOAD { my $s = shift; our $AUTOLOAD; my ($key) = $AUTOLOAD =~ m/([^:]+)$/; return exists($s->{$key}) ? $s->{$key} : die "Invalid field '$key'"; }# end AUTOLOAD() sub DESTROY {} 1;# return true: __END__