Welcome Guest, Not a member yet? Register   Sign In
Is it bad to not pass params to Model Class?
#1

[eluser]bret[/eluser]
Beginner here. I was just curious what is best:

This is what I currently have and it works:

In my Controller:
Code:
$this->registration_functions->create_member()


In my Model Class, within the function:create_member():
Code:
'user_email' => $this->input->post('email_address')


Are there any positives or negatives of doing it this way rather than passing paramaters to the function? For example...

Code:
$this->registration_functions->create_member($user_email)

Thanks in advance
#2

[eluser]Eric Barnes[/eluser]
Ideally the second would be the best because in CodeIgniter all form validation is done in the controller. So you should do your validation on the post data first then send it to the model.
#3

[eluser]kcmerrill[/eluser]
I agree with Eric, also it helps with testing purposes and makes the method more robust down the line.
-kc
#4

[eluser]bret[/eluser]
Thanks for the replies. Smile




Theme © iAndrew 2016 - Forum software by © MyBB