• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confusion on how to handle data from view (form input)

#1
[eluser]Unknown[/eluser]
Hello! I'm brand new to posting on the forums so hopefully this is the right place.

I just recently starting learning PHP and databases and now learning CI. My background comes from C++ and Java, but only with simple OOP that didn't include saving data anywhere.

My confusion comes from trying to get a grasp of MVC in how to pass the data received in form input from the view. Reading the CI userguide and searching through many other posts, I have seen a variety of ways to do this, but I'm wondering what is the most common approach. Here's what I have played around with:

1. The Form action in the view calls the controller, the controller calls the model's add method, the model in its add method assigns the post data in an array and inserts the array into the DB.

2. The Form action in the view calls the controller, the controller assigns the post data in an array, passes the array to the model's add method which inserts array into the database.

3. The form action in the view calls the controller, the model now has properties which get assigned to the post data, the controller then calls the model's add method with no parameters, the model's add method uses its assigned properties and performs an insert into the DB.


Also as another question, since I'm so used to C++ and Java I'm having a tough time relating to what there how I thought of classes and objects, to how a model works. Do model's have class properties which get assigned, or are they just used to read and write data to a table whose fields define its properties?

Sorry if I was unclear explaining anything, thanks in advance for any help!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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