Re: [CDBI] How do you get the raw db value of a column rather than inflated object

[prev] [thread] [next] [Date index for 2006/02/11]

From: Bill Moseley
Subject: Re: [CDBI] How do you get the raw db value of a column rather than inflated object
Date: 23:31 on 11 Feb 2006
On Sat, Feb 11, 2006 at 03:16:58PM -0600, Peter Speltz wrote:
> On 2/11/06, Bill Moseley <moseley@xxxx.xxx> wrote:
> > On Sat, Feb 11, 2006 at 06:57:32AM -0600, Peter Speltz wrote:
> >
> >   $object->my_column->id
> 
> 
> Problem with that is you have to know you are dealing with an inflated
> column and also a CDBI object in order to accurately get at the raw
> value.   Has_a s can be inflated to any object.  I could call deflate
> explicitly but it is not documented how to do that and  I cant remeber
> if it is possible. I posted a while back asking. Need to search for
> that thread.

I'm curious.  Why do you need the raw column value in addition to the
inflated value?

I wonder if you could do something like this in your base class:

<untested>

sub _attribute_store {
    my $self = shift;
    my $vals   = @_ == 1 ? $_[0] : {@_};
    for my $key ( keys %$vals ) {
        next if ref $vals->{$key};
        $self->{$key . '_raw'} = $vals->{$key};
    }
    $self->SUPER::_attribute_store( @_ );

}

</untested>

The you would ask for

    my $value = $object->{my_column_raw};






        -- 
        Bill Moseley
moseley@xxxx.xxx


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

Re: [CDBI] How do you get the raw db value of a column rather than inflated object
Bill Moseley 23:31 on 11 Feb 2006

Generated at 10:41 on 18 Feb 2006 by mariachi v0.52