Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dbix::class::filtercolumn(3) [mojave man page]

DBIx::Class::FilterColumn(3)				User Contributed Perl Documentation			      DBIx::Class::FilterColumn(3)

NAME
DBIx::Class::FilterColumn - Automatically convert column data SYNOPSIS
In your Schema or DB class add "FilterColumn" to the top of the component list. __PACKAGE__->load_components(qw( FilterColumn ... )); Set up filters for the columns you want to convert. __PACKAGE__->filter_column( money => { filter_to_storage => 'to_pennies', filter_from_storage => 'from_pennies', }); sub to_pennies { $_[1] * 100 } sub from_pennies { $_[1] / 100 } 1; DESCRIPTION
This component is meant to be a more powerful, but less DWIM-y, DBIx::Class::InflateColumn. One of the major issues with said component is that it only works with references. Generally speaking anything that can be done with DBIx::Class::InflateColumn can be done with this component. METHODS
filter_column __PACKAGE__->filter_column( colname => { filter_from_storage => 'method'|&coderef, filter_to_storage => 'method'|&coderef, }) This is the method that you need to call to set up a filtered column. It takes exactly two arguments; the first being the column name the second being a hash reference with "filter_from_storage" and "filter_to_storage" set to either a method name or a code reference. In either case the filter is invoked as: $result->$filter_specification ($value_to_filter) with $filter_specification being chosen depending on whether the $value_to_filter is being retrieved from or written to permanent storage. If a specific directional filter is not specified, the original value will be passed to/from storage unfiltered. get_filtered_column $obj->get_filtered_column('colname') Returns the filtered value of the column set_filtered_column $obj->set_filtered_column(colname => 'new_value') Sets the filtered value of the column EXAMPLE OF USE
Some databases have restrictions on values that can be passed to boolean columns, and problems can be caused by passing value that perl considers to be false (such as "undef"). One solution to this is to ensure that the boolean values are set to something that the database can handle - such as numeric zero and one, using code like this:- __PACKAGE__->filter_column( my_boolean_column => { filter_to_storage => sub { $_[1] ? 1 : 0 }, } ); In this case the "filter_from_storage" is not required, as just passing the database value through to perl does the right thing. INHERITED METHODS
DBIx::Class::Row copy, delete, discard_changes, get_dirty_columns, get_from_storage, get_inflated_columns, has_column_loaded, in_storage, inflate_result, insert, insert_or_update, is_changed, is_column_changed, make_column_dirty, register_column, result_source, set_column, set_columns, set_inflated_columns, throw_exception, update_or_insert perl v5.18.2 2014-01-30 DBIx::Class::FilterColumn(3)

Check Out this Related Man Page

DBIx::Class::Manual::ResultClass(3)			User Contributed Perl Documentation		       DBIx::Class::Manual::ResultClass(3)

NAME
DBIx::Class::Manual::ResultClass - Representing a single result (row) from a DB query SYNOPSIS
package My::Schema::Result::Track; use parent 'DBIx::Class::Core'; __PACKAGE__->table('tracks'); __PACKAGE__->add_columns({ id => { data_type => 'int', is_auto_increment => 1, }, cd_id => { data_type => 'int', }, title => { data_type => 'varchar', size => 50, }, rank => { data_type => 'int', is_nullable => 1, }, }); __PACKAGE__->set_primary_key('id'); __PACKAGE__->add_unique_constraint(u_title => ['cd_id', 'title']); DESCRIPTION
In DBIx::Class, a user normally receives query results as instances of a certain "Result Class", depending on the main query source. Besides being the primary "toolset" for interaction with your data, a "Result Class" also serves to establish source metadata, which is then used during initialization of your DBIx::Class::Schema instance. Because of these multiple seemingly conflicting purposes, it is hard to aggregate the documentation of various methods available on a typical "Result Class". This document serves as a general overview of "Result Class" declaration best practices, and offers an index of the available methods (and the Components/Roles which provide them). INHERITED METHODS
DBIx::Class::Relationship has_many, has_one, might_have, belongs_to, many_to_many DBIx::Class::Relationship::Base register_relationship, count_related, create_related, delete_related, find_or_create_related, find_or_new_related, find_related, new_related, related_resultset, search_related, search_related_rs, set_from_related, update_from_related, update_or_create_related DBIx::Class::InflateColumn get_inflated_column, inflate_column, set_inflated_column, store_inflated_column DBIx::Class::PK ID, id, ident_condition DBIx::Class::Row delete, update, copy, discard_changes, get_column, get_columns, get_dirty_columns, get_from_storage, get_inflated_columns, has_column_loaded, in_storage, inflate_result, insert, insert_or_update, is_changed, is_column_changed, make_column_dirty, new, register_column, result_source, set_column, set_columns, set_inflated_columns, store_column, throw_exception, update_or_insert DBIx::Class::ResultSourceProxy::Table table, table_class DBIx::Class::ResultSource add_column, add_columns, add_relationship, add_unique_constraint, add_unique_constraints, column_info, column_info_from_storage, columns, columns_info, has_column, has_relationship, primary_columns, relationship_info, relationships, remove_column, remove_columns, result_class, resultset_attributes, resultset_class, sequence, set_primary_key, source_info, source_name, unique_constraint_columns, unique_constraint_names, unique_constraints AUTHOR AND CONTRIBUTORS
See AUTHOR and CONTRIBUTORS in DBIx::Class LICENSE
You may distribute this code under the same terms as Perl itself. perl v5.18.2 2014-01-30 DBIx::Class::Manual::ResultClass(3)
Man Page