Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Default "blank" table record?

Quote Reply
Default "blank" table record?
Alex,

Is there a way to get a hash back of the table values, and have each value initialized to it's default?

This way, in routines that need to manipulate both new and existing data, you can avoid the overhead of constantly checking whether a field exists or is defined?

For example:

# This will set system fields like Validated to their proper values.
foreach my $key (keys %{$CFG->{add_system_fields}}) {
$IN->param(-name => $key, -value => $CFG->{add_system_fields}->{$key});
}

I'm looking for something like this that would set all the values in a %rec to their defaults.

I don't understand, from a modular issue, why the values for the new link are being pushed into %CFG instead of a %$rec where $rec is the reference to a database table record, since in a loop the values of %$rec would change, but %CFG should not.


PUGDOG®
PUGDOG® Enterprises, Inc.
FAQ: http://postcards.com/FAQ


Quote Reply
Re: Default "blank" table record? In reply to
Hi,

Hmm:

my $table = $DB->table('Links');
my %defaults = $table->default;

=)

In Reply To:
I don't understand, from a modular issue, why the values for the new link are being pushed into ÏG instead of a %$rec where $rec is the reference to a database table record, since in a loop the values of %$rec would change, but ÏG should not.
I think you are missing what that is doing, it's putting the values in CFG into the cgi object, CFG is not changing at all.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Default "blank" table record? In reply to
Yeah, I think I figured the CFG thing out about 2 hours later. I probably should have tried to do a "Hello World" first... <G>

But, this auction thing is working out well so far. The templates are taking an incredible amount of time.

PUGDOG®
PUGDOG® Enterprises, Inc.
FAQ: http://postcards.com/FAQ