Re: Getting a New CDBI object without creating one in db?

[prev] [thread] [next] [Date index for 2004/10/22]

From: Perrin Harkins
Subject: Re: Getting a New CDBI object without creating one in db?
Date: 16:44 on 22 Oct 2004
On Tue, 2004-10-19 at 07:53, Andreas Fromm wrote:
> actually, I don't have a ready form to populate, but was doing things
> like this:
> 
> foreach my $field ( $person->all ){
> ~  if ( UNIVERSAL::isa(ref $person->$field, 'Class::DBI') ){
> ~    .... do something with the referenced class fields ...
> ~    .... for example:
> ~      foreach my $subfield ( $person->$field->all ){
> ~         ....
> ~      }
> ~  } else {
> ~    .... do something with the fields, ....
> ~    .... for example write a form input ....
> ~  }
> }
> 
> The test for UNIVERSAL::isa(ref $person->$field, 'Class::DBI') will
> never be true if the object isn't instantiated. What I did then was to
> creacte an empty object, populate everything with 'undef' and then
> discarded the object once I had the structure with all the references of
> the fields, but thats clearly not an efficient way of doing things.

Yeah, definitely not.  You could avoid the whole "need an empty object"
issue by asking the class (not an object) what fields it has and which
ones have relationships.  That would be much better than trying to make
Class::DBI create objects that aren't tied to database records.

- Perrin

(message missing)

domain cross talk...?
Michael Jensen 06:47 on 06 Oct 2004

Re: domain cross talk...?
William McKee 14:41 on 06 Oct 2004

Re: domain cross talk...?
Perrin Harkins 14:47 on 06 Oct 2004

Re: domain cross talk...?
William McKee 14:51 on 06 Oct 2004

Re: domain cross talk...?
Perrin Harkins 15:06 on 06 Oct 2004

Re: domain cross talk...?
William McKee 15:32 on 06 Oct 2004

Re: domain cross talk...?
Perrin Harkins 15:36 on 06 Oct 2004

Re: domain cross talk...?
Michael Jensen 16:03 on 06 Oct 2004

Re: domain cross talk...?
Michael Jensen 16:16 on 06 Oct 2004

Re: domain cross talk...?
Perrin Harkins 16:27 on 06 Oct 2004

Re: domain cross talk...?
Carl Johnstone 23:17 on 06 Oct 2004

Re: domain cross talk...?
William McKee 15:53 on 06 Oct 2004

Re: domain cross talk...?
merlyn (Randal L. Schwartz) 16:17 on 06 Oct 2004

Re: domain cross talk...?
Perrin Harkins 16:31 on 06 Oct 2004

[CDBI] Class::DBI::Loader question
Peter Speltz 00:31 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Kingsley Kerce 02:57 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Perrin Harkins 04:12 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Kingsley Kerce 18:43 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Clayton L. Scott 17:08 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Peter Speltz 17:32 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Perrin Harkins 18:58 on 12 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Kingsley Kerce 14:26 on 14 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Perrin Harkins 15:17 on 14 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Tony Bowden 15:39 on 14 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Kingsley Kerce 14:26 on 14 Oct 2004

Re: [CDBI] Class::DBI::Loader question
Tim Bunce 16:22 on 14 Oct 2004

Re: [CDBI] Class::DBI::Loader question
merlyn (Randal L. Schwartz) 17:24 on 14 Oct 2004

Re: Getting a New CDBI object without creating one in db?
Perrin Harkins 16:44 on 22 Oct 2004

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