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: Peter Speltz
Subject: Re: [CDBI] How do you get the raw db value of a column rather than inflated object
Date: 21:16 on 11 Feb 2006
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.
So for now I am stuck with code like this  to get going. . Will fix
better later.


if (my $type =3D ref $obj->my_col) {
  # How the hell do we get the value thats in the database???
  if (eval { $obj->my_col->isa("Class::DBI") } ) {
    return $obj->my_col->id;
  } elsif (eval {$obj->my_col->isa("Time::Piece") {
    return $obj->my_col->mysql_datetime;
  } elsif (eval {$obj->my_col->isa("Date::Simple") {
     ...
  } else {
    die "Unknown type -- $type -- associated with has_a. ";
  }
}

else { return $obj->my_col }


cheers,


--
pjs

_______________________________________________
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
Peter Speltz 21:16 on 11 Feb 2006

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