DBIx::Class::DynamicDefault man page on Fedora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Fedora logo
[printable version]

DBIx::Class::DynamicDeUsertContributed Perl DocuDBIx::Class::DynamicDefault(3)

NAME
       DBIx::Class::DynamicDefault - Automatically set and update fields

SYNOPSIS
	 package My::Schema::SomeTable;

	 __PACKAGE__->load_components(qw/DynamicDefault ... Core/);

	 __PACKAGE__->add_columns(
		 quux	       => { data_type => 'integer' },
		 quux_plus_one => { data_type => 'integer',
				    dynamic_default_on_create => \&quux_plus_one_default,
				    dynamic_default_on_update => 'quux_plus_one_default', },
		 last_changed  => { data_type => 'integer',
				    dynamic_default_on_create => 'now',
				    dynamic_default_on_update => 'now, },
	 );

	 sub quux_plus_one_default {
	     my ($self) = @_;
	     return $self->quux + 1;
	 }

	 sub now {
	     return DateTime->now->epoch;
	 }

       Now, any update or create actions will set the specified columns to the
       value returned by the callback you specified as a method name or code
       reference.

DESCRIPTION
       Automatically set and update fields with values calculated at runtime.

OPTIONS
   dynamic_default_on_create
	 dynamic_default_on_create => sub { ... }

	 dynamic_default_on_create => 'method_name'

       When inserting a new row all columns with the
       "dynamic_default_on_create" option will be set to the return value of
       the specified callback unless the columns value has been explicitly
       set. The callback, that'll be invoked with the row object as its only
       argument, may be a code reference or a method name.

   dynamic_default_on_update
	 dynamic_default_on_update => sub { ... }

	 dynamic_default_on_update => 'method_name'

       When updating a row all columns with the "dynamic_default_on_update"
       option will be set to the return value of the specified callback unless
       the columns value has been explicitly set.

       Columns will only be altered if other dirty columns exist. See
       "always_update" on how to change this.

   always_update
	 always_update => 1

       When setting "always_update" to 1 "dynamic_default_on_update" callbacks
       will always be invoked, even if no other columns are dirty.

AUTHOR
       Florian Ragwitz <rafl@debian.org>

LICENSE
       This software is copyright (c) 2008 by Florian Ragwitz.

       This is free software; you can redistribute it and/or modify it under
       the same terms as perl itself.

perl v5.14.2			  2012-04-14	DBIx::Class::DynamicDefault(3)
[top]

List of man pages available for Fedora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net