GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Jifty::DBI::Filter(3) User Contributed Perl Documentation Jifty::DBI::Filter(3)

Jifty::DBI::Filter - base class for Jifty::DBI filters

  # To implement your own filter
  package MyApp::Filter::Uppercase;
  use base qw/ Jifty::DBI::Filter /;

  # Setup for DB storage, store in lowercase
  sub encode {
      my $self = shift;

      my $value_ref = $self->value_ref;
      return unless defined $$value_ref; # don't blow up on undef

      $$value_ref = lc $$value_ref;
  }

  # Setup for Perl code to use, always sees uppercase
  sub decode {
      my $self = shift;

      my $value_ref = $self->value_ref;
      return unless defined $$value_ref; # don't blow up on undef

      $$value_ref = uc $$value_ref;
  }

  # To use a filter
  use MyApp::Record schema {
      column filtered =>
          type is 'text',
          filters are qw/ MyApp::Filter::Uppercase /;
  };

A filter allows Jifty::DBI models to tweak data prior to being stored and/or loaded. This is useful for marshalling and unmarshalling complex objects.

Takes three arguments in a parameter hash:
value_ref
A reference to the current value you're going to be massaging. "encode" works in place, massaging whatever value_ref refers to.
column
A Jifty::DBI::Column object, whatever sort of column we're working with here.
handle
A Jifty::DBI::Handle object, because some filters (i.e. Jifty::DBI::Filter::Boolean) depend on what database system is being used.

"encode" takes data that users are handing to us and marshals it into a form suitable for sticking it in the database. This could be anything from flattening a DateTime object into an ISO date to making sure that data is utf8 clean.

"decode" takes data that the database is handing back to us and gets it into a form that's OK to hand back to the user. This could be anything from inflating an ISO date to a DateTime object to making sure that the string properly has the utf8 flag.

Jifty::DBI::Filter::Date, Jifty::DBI::Filter::DateTime, Jifty::DBI::Filter:SaltHash, Jifty::DBI::Filter::Storable, Jifty::DBI::Filter::Time, Jifty::DBI::Filter::Truncate, Jifty::DBI::Filter::YAML, Jifty::DBI::Filter::base64, Jifty::DBI::Filter::utf8

Jifty::DBI is Copyright 2005-2007 Best Practical Solutions, LLC. Jifty::DBI is distributed under the same terms as Perl itself.
2014-05-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.