IMHO I would do the following:

 

Assuming you have 2 tables, one for personal info such name and last name and the other for address info.  The address info table would have to also have an address type column.  For example, 1 stands for home, 2 for business, etc etc.

 

Now I would go ahead and create getAddress() function with an optional argument called addressType..

 

So that if the suer specifies john.getAddress(2), the function would return a biz address, while, john.getAddress would return the users home address.

 

I hope this helps.

 

Sean Scott

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Mineer
Sent: Wednesday, August 06, 2003 2:24 PM
To: cfcdev
Subject: [CFCDev]

 

I have Hal's book and was reading his article on macromedia, and also reading all the posts to this list.  I am trying to cement in my mind oop and cfc's.  Can someone give me an idea on the following.

 

Almost every page I have has some kind of db interaction.  Using Hal's example of composition, a person has an address, I would like to understand how to best implement this using a cfc.  But, I want to understand it from the point of a person having more than one address, a one-to-many relationship.

 

If I have a list of persons in a database, with 1 or more addresses linked via a separate table, how do I code this using a cfc (getting info on a person from the db given their id). Right now I would simply link the two using some type of sql join in a single cfc.  But I am wondering if there is a better way calling a separate cfc (address.cfc) that would give me better encapsulation and such.

 

TIA,

 

---------------------
David Mineer

 

---------------------
Don't wish it was easier; wish you were better.
Don't wish for less problems; wish for more skills.
Don't wish for less challenges; wish for more wisdom.

Reply via email to