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

Peter Speltz peterspeltz at gmail.com
Sat Feb 11 21:16:58 GMT 2006

On 2/11/06, Bill Moseley <moseley at hank.org> 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 = 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 }



More information about the ClassDBI mailing list