I have always seen parameters passed to model methods in the form $this->example_model->method('Some Title');
I recently saw an answer on here (can’t find it now) that said that a properly created model should receive parameters to a method like this:
$this->example_model->method->title = 'Some Title';
I can’t seem to figure out how to do this, what would the model method look like to achieve this? Is this truly how parameters should be passed?
Well, depends on needs and usage.
Say I need to pull ALL entries from a database table in my model – this would be fine:
$this->example_model->get();Say I have a need to get all entries based on some criterias. I would probably do something like this:
What you are thinking of accomplishing would be something more like this:
Or you could go with something more ideal for method binding:
Basically, all solutions are fine – not one of them is the most correct and there are still several ways of accomplishing the same. But some are more readable than others (and less prone to errors). You should choose whatever works for you and you are comfortable to work with.