[prev] [thread] [next] [Date index for 2004/11/04]
oops, i see i sent this to the wrong list las time. broke the thread. sorry. --- Tony Bowden <tony-maypole@xxxxx.xxx> wrote: > On Wed, Nov 03, 2004 at 05:39:30PM -0800, Peter Speltz wrote: > > So, the ideal solution would be to add an additional field to the > > create_from_cgi which would allow you to use it like this: > > my $customer = Customer->create_from_cgi( $h => { additional => {user_id => > $session->usr_id} } ); > > > Then you get the power of FromCGI with the freedom of CDBI::create. The > docs > > would change like so: > > $film->update_from_cgi($h => { > > all => \@all_columns, # auto-filled if left blank > > ignore => \@cols_to_ignore, > > required => \@cols_needed, > > additional => \%cols_and_values_not_in_form > > }); > > I tend to do that by adding those values into what will become $h in > your example, before ever calling update_from_cgi with it... > That would work that simple example when only one object is created from CGI. But what if you have many objects created from same form and 2 of the objects ids become foreign keys in the 3rd object? I tried to look for a way to add things to $h but didn't see a public interface to that. Heres a block of code that has this problem: sub create_employee { # form has inputs for Person, User, and Employee tables. # Employee is a person and user and thus person_id and user_id as foreign # keys. .. . # Can't add usr_id nad person_id to params yet because i don't have them my $h = CGI::Untaint->new( %{ $r->{params} } ); $usr_obj = BttlBks::Usr->create_from_cgi($h); $prsn_obj = BttlBks::Person->create_from_cgi( $h ); $emplyee_obj = Employee->create_from_cgi( $h ); # now the part I want to avoid $employee->usr_id($usr_obj->id); $employee->prsn_id($prsn_obj->id); $employee->update; } See? IT's rare in my databases to have a business object encpasulated in only one table. As i see it, this lack of "additional" functionality renders FromCGI virutally useless for creating a composite database object on one form (Which is arguably the way users like to do it if feasible). However i'm a newbie so i'm wondering what i'm missing here that this doesn't seem like a useful addition to anyone. thanks ===== pjs __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: create_from_cgi question
|
Generated at 11:34 on 01 Dec 2004 by mariachi v0.52