Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dbix::class::timestamp(3pm) [debian man page]

DBIx::Class::TimeStamp(3pm)				User Contributed Perl Documentation			       DBIx::Class::TimeStamp(3pm)

NAME
DBIx::Class::TimeStamp - DBIx::Class extension to update and create date and time based fields DESCRIPTION
Works in conjunction with InflateColumn::DateTime to automatically set update and create date and time based fields in a table. SYNOPSIS
package My::Schema; __PACKAGE__->load_components(qw( TimeStamp ... Core )); __PACKAGE__->add_columns( id => { data_type => 'integer' }, t_created => { data_type => 'datetime', set_on_create => 1 }, t_updated => { data_type => 'datetime', set_on_create => 1, set_on_update => 1 }, ); Now, any update or create actions will update the specified columns with the current time, using the DateTime inflator. This is effectively trigger emulation to get consistent behavior across databases that either implement them poorly or not at all. METHODS
get_timestamp Returns a DateTime object pointing to now. Override this method if you have different time accounting functions, or want to do anything special. The date and time objects in the database are expected to be inflated. As such you can be pretty flexible with what you want to return here. AUTHOR
J. Shirley <jshirley@gmail.com> CONTRIBUTORS
Florian Ragwitz (Porting to DBIx::Class::DynamicDefault) LTJake/bricas COPYRIGHT &; LICENSE Copyright 2009 J. Shirley, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2010-09-05 DBIx::Class::TimeStamp(3pm)

Check Out this Related Man Page

DBIx::Class::DynamicDefault(3pm)			User Contributed Perl Documentation			  DBIx::Class::DynamicDefault(3pm)

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(3pm)
Man Page