RE: Question about creation of records on many tables

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

From: Zhuang Li
Subject: RE: Question about creation of records on many tables
Date: 18:43 on 22 Sep 2004
It seems the hash should be:
$user =3D { name =3D> 'Paul',
	     Address =3D> {
	  street =3D> 'Homelane',
	  number =3D> '56'
	     },
	};

Then MyClass::Users->create($user).

john


-----Original Message-----
From: Andreas Fromm [mailto:Andreas.Fromm@xxxxxx.xxxxxxxxxxxx.xx]=20
Sent: Wednesday, September 22, 2004 3:05 AM
To: cdbi-talk@xxxxxx.xxxxx.xxx
Subject: Question about creation of records on many tables

Hi,

Please consider the following Database

CREATE TABLE Users (
    id		serial PRIMARY KEY,
    name	text,
    address	int(4) references Addresses
);


CREATE TABLE Adresses (
    id		serial PRIMARY KEY,
    street	text,
    number	text,
);

Is it possible to set the CDBI-classes in such a way the if I pass a
hash containing the data for a new user with adress e.g.

$user =3D { name =3D> 'Paul',
	  street =3D> 'Homelane',
	  number =3D> '56'
	};

to the create method of Users like in
   MyClass::Users->( $user );

I get the correct behavior that the adress-record is created first and
the id is used in the user-record, all by itself, or do I have to take
care to create the address-record first?

Thanks in advance.

Andreas Fromm




Question about creation of records on many tables
Andreas Fromm 10:05 on 22 Sep 2004

RE: Question about creation of records on many tables
Zhuang Li 18:43 on 22 Sep 2004

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