Re: Inflate/deflate to formatted text

[prev] [thread] [next] [Date index for 2004/09/14]

From: Brian Webb
Subject: Re: Inflate/deflate to formatted text
Date: 22:31 on 14 Sep 2004
I want to do something similar. One of my column types in my MySQL database is
a "set". A query will return a comma-delimited string of all elements. When I
access that column via my Class::DBI object I want to have an array reference
interface, ie

$obj = MyClass->retrieve( 1 );
$arr_ref = $obj->my_set_column();
print $arr_ref; # prints 'ARRAY'
$obj->my_set_column( \@another_list );

This used to work in Class-DBI-0.94. Class-DBI-0.96 attempts to call the isa()
method on my $obj (which fails). Is there a reason why inflate/deflate requires
an object reference and not a built-in perl data type?

- Brian

--- Perrin Harkins <perrin@xxxx.xxx> wrote:

> On Tue, 2004-09-14 at 15:46, William McKee wrote:
> > I have a field in my database which I would like to present in a
> > formatted string when retrieved. It's not a date so the sample
> > inflate/deflate code does not work. I have tried using an empty class
> > when setting up the has_a relationship but CDBI complains. There is
> > really no appropriate base class; I just need to do a sprintf on a value
> > to get a better format. Is there a way to handle this without using a
> > base class?
> 
> You have to inflate it an object if you want to use has_a.  You can
> inflate it to an IO::Scalar object, or something simple of your own
> making.  If that sounds like too much, just do the formatting somewhere
> else when you read from the CDBI object.
> 
> - Perrin
> 
> 


	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

Inflate/deflate to formatted text
William McKee 19:46 on 14 Sep 2004

Re: Inflate/deflate to formatted text
Perrin Harkins 19:53 on 14 Sep 2004

Re: Inflate/deflate to formatted text
Brian Webb 22:31 on 14 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52