Dynamically call object instances

Shandy Nantz wrote:

Hi again,

I have these functions - about five of them - and they are all the exact same code except for which object instances they are referencing. For example, if I have a user object and each user can modify one of five phone fields - home, work, cell, etc. - I would like to call one function and just pass a varibale indicating which one I am modifying.

This is not a direct answer to your question since the answer has already been provided. But, I just wanted to point out that you might be struggling with this because your model breaks the First Normal Form (1NF) of database design, which states that a table should contain no repeating groups.

In this case the repeating groups would be home_phone, work_phone cell_phone, etc. These are all phone numbers making up a repeating group and should, technically, be normalized, which also cleanly solves the problem at hand.

phones   id | person_id | label | number    1 | 1 | home | 555-123-1234    2 | 1 | work | 555-123-2345