• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting data into several tables

#1
[eluser]Jesse Schutt[/eluser]
Evening all!

I was wondering if someone could steer me in the correct direction regarding the proper method for collecting data from a form and distributing it into several different tables in the DB.

For example:
I am working on a registration form that collects an individuals contact information, the event they would like to register for, and the payment information. This information is stored in several different tables.

Theoretically speaking, is it best to create several different arrays from the cleaned POST and send them to different functions in my model? The functions would then do the inserts?

Thanks much!

Jesse

#2
[eluser]Colin Williams[/eluser]
If the objects you are saving are tightly coupled, then it might be a better API to have a single model function to handle the insert. You can make your model functions smart and flexible. Like, if they encounter extra data, they can initiate the process of storing the extra stuff where it needs. The controller shouldn't need to know to much about how and where the data is stored. This is the model's game.

#3
[eluser]Jesse Schutt[/eluser]
Colin,

Thanks for the reply!

Say I have a basic table structure like this:

person
person_id
name
etc

event
event_id
event_name
cost
etc

registration
registration_id
person_id
event_id

Can you give me some help on the order of operations needed in the model to do this?

All of the information is collected/generated in the form and controller.

Thanks so much!

Jesse

#4
[eluser]Jesse Schutt[/eluser]
Or if anyone has a model they would like to show off that relates to this...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.