From: Robert Krimen Date: Tue, 6 Feb 2007 19:40:00 +0000 (+0000) Subject: Added; X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1697e138eeb96cab5ab20c35a8834cf8ce5106d1;p=dbsrgits%2FDBIx-Class-Historic.git Added; FAQ-fetch-a-formatted-column.txt FAQ-store-JSON-in-a-column.txt --- diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index 2117896..540bd21 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -255,6 +255,17 @@ Call C on a L, this returns a L, see it's documentation and the L for details. +=item .. fetch a formatted column? + +In your table schema class, create a "private" column accessor with: + + __PACKAGE__->add_columns(my_common => { accessor => '_hidden_my_column' }); + +Then, in the same class, implement a subroutine called "my_column" that +fetches the real value and does the formatting you want. + +See the Cookbook for more details. + =back =head2 Inserting and updating data @@ -296,6 +307,18 @@ scalar reference: ->update({ somecolumn => \'othercolumn' }) +=item .. store JSON in a column and have it deflate/inflate automatically? + +In your table schema class, do the following: + + use JSON; + + __PACKAGE__->add_columns(qw/ ... my_column ../) + __PACKAGE__->inflate_column('my_column', { + inflate => sub { jsonToObj(shift) }, + deflate => sub { objToJson(shift) }, + }); + =back =head2 Misc