[Dbix-class] Using DBIx::Class::InflateColumn
Christopher H. Laco
claco at chrislaco.com
Tue May 29 17:47:21 GMT 2007
Eduard Gim=E9nez wrote:
> =
> Hi,
> =
> I'm trying to use DBIx::Class::InflateColumn to inflate some date columns,
> so I put that on the model (it's a Catalyst App attacking a MySQL DB).
> =
> __PACKAGE__->inflate_column('creation_time', {
> inflate =3D> sub { DateTime::Format::MySQL->parse_datetime(shift)=
; },
> deflate =3D> sub { DateTime::Format::MySQL->format_datetime(shift=
); },
> });
InflateColumn::DateTime is your friend. There isn't a good reason to
roll your own inflators/deflators for datetime fields.
> =
> It works well, but I have to access to this column using
> get_inflated_column("creation_time")
"have to"? Why no just use the accessor? $obj->creation_time ?
. I would like to get the inflated
> result for each request, so doing simply a get_column("creation_time") wo=
uld
> be enough.
Does not compute. get_column returns the raw DB value, not the inflated
object. If you're after the inflated object, use the accessor:
$obj->creation_time. There's usually no good need for most people to
dive into anything other than that....esp get_inflated_column.
> =
> I couldn't find a way to do that, so now I'm trying to overload the
> inflate_result method, so it will parse each row and each column inflating
> the desired ones. =
Huh?
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070529/19=
16ced2/signature.pgp
More information about the Dbix-class
mailing list