Welcome Guest, Not a member yet? Register   Sign In
What goes where? (MVC)
#9

[eluser]TheFuzzy0ne[/eluser]
[quote author="SomeFunkyDude" date="1239324143"]OK, it's starting be a little clearer for me now, the Controller is JUST the traffic cop, any classes/functions/processing/logic/database processing, etc. should be in the model, the view should mostly be html, basic data displaying templates, or simple loop or if/else statements.[/quote]

I wouldn't go as far as to say all processing and logic must be a model. Obviously you can use libraries, plugins and helpers too.

[quote author="SomeFunkyDude" date="1239324143"]Can you assign the Boolean 'false' to $id in the method's arguments, and wouldn't that always make if(!$id) return false thus always redirecting to the home page.[/quote]

FALSE is only assigned by default, if the argument provided is NULL (not specifying an argument throws NULL in by default). If NULL is not provided as the argument, then the supplied value is stored. Setting the default value is a great way to stop those errors you see when you don't supply an argument to a function:

Code:
echo date();

# Produces Warning: date() expects at least 1 parameter, 0 given in ./system/- on line 2

But then again, sometimes this behaviour is desirable.

[quote author="SomeFunkyDude" date="1239324143"]Also, in the line:
Code:
$product = $this->product->get_all_data($id)
this wouldn't work unless the controller also loaded a model that has property of 'product' and method of 'get_all_data()' right?[/quote]

Yes, but the model can be auto-loaded or loaded in the controllers constructor. Don't forget, that example was fictitious, although syntactically sound.


Messages In This Thread
What goes where? (MVC) - by El Forum - 04-09-2009, 11:30 AM
What goes where? (MVC) - by El Forum - 04-09-2009, 11:40 AM
What goes where? (MVC) - by El Forum - 04-09-2009, 12:03 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 12:29 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 01:26 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 01:42 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 01:50 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 01:57 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 02:07 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 02:08 PM
What goes where? (MVC) - by El Forum - 04-09-2009, 03:59 PM
What goes where? (MVC) - by El Forum - 05-22-2009, 10:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB