Welcome Guest, Not a member yet? Register   Sign In
Having Trouble understanding concept of passing data from model to controller
#2

(09-08-2015, 05:10 PM)amwh Wrote: I am inserting data that has been entered in a form view to a table.  Based on the value of one of the fields, I may need to insert the same data into a different table.  I can insert the data into both tables; but I am having a difficult time retrieving the value in the field and "sending" it to the controller.

When you say "based on the value of one of the fields," isn't that a field that was entered in the form view or calculated in the controller? You don't say what the application is, but suppose I have a form with name and street address, and maybe it's a "friend" or maybe it's a "contact." I know this before calling the model, so I don't need to pass data from the model to the controller.

However, you can easily return data from the model to the controller if you just place it in the return statement of a method/function. For example, in my user controller, in the login() method, I have:

PHP Code:
$valid_login $this->user_model->validate_login($data);
if (
$valid_login)
{
    
// do whatever

So validate_login() receives $data, but happens to return a true or false, and that is stored in $valid_login.

If I didn't understand your question, sorry, maybe give more details. Smile
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply


Messages In This Thread
RE: Having Trouble understanding concept of passing data from model to controller - by RobertSF - 09-08-2015, 05:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB