A couple days ago, I lamented that Find* didn't return an array of
model objects. I posted about it here, and I was told that one of the
reasons for this was that it would be too tempting to start
inserting business logic in the views if you had objects available
there.
Fine. I'll concede that
Deane,
I have to disagree with your opinion that the business logic belongs
in the controllers. From my understanding of MVC best practices,
specifically Fat models, skinny controllers - the models should be
responsible for the business logic, not the controllers. The
controllers are pretty much
MyTufty:
the models should be responsible for the business logic, not the controllers
Fine, I'll concede that point and code up a ton of business logic in
my models.
Still, my controller needs to call the business logic at some point.
The controller needs to say, Hey, model, do *this*...
If I
On Jan 7, 2008 10:29 AM, Deane [EMAIL PROTECTED] wrote:
If I can't get clean access to model objects in my controllers, how am
I to do this?
Deane
I don't understand why it's so hard to accept that a call to a CakePHP
DB model returns an array of results? I may have taken computer
science
The models are available in the controller..
$results = $this-ModelName-
someFunctionYouWroteToGetSomDataBackFromTheDb();
unfortunately cake returns an array of results instead of an object..
so there no doing something like..
$results-sortBy('date ASC');
On Jan 7, 7:38 am, Deane [EMAIL
That example you gave -- is that a static method on the class? What
if I want to instantiate a specific Widget object (from a specific row
in the database) and run an instance method on it?
On Jan 7, 10:32 am, kristofer [EMAIL PROTECTED] wrote:
The models are available in the controller..
On Jan 7, 9:26 pm, Deane [EMAIL PROTECTED] wrote:
That example you gave -- is that a static method on the class? What
if I want to instantiate a specific Widget object (from a specific row
in the database) and run an instance method on it?
$this-Model-read(null, $id);
Two ways jump out at me right off the bat. First, think of the default
cake Model as a data access class only, and then define a business-
logic class (that doesn't extend AppModel) to encapsulate your desired
model functionality.
// Get results from data access model
$results =
I had similar feelings to this when I first had to get some complex
data through CakePHP, thinking the results of a simple mysql_query or
an object would be much easier to work with than a 5 level deep array!
Yet I still have nothing but these big arrays to deal with.
That's the key point, and
Assume this scenario:
I need to retrieve 20 records, and call a method on each of them. So
I do my Find, and get back an array. I then spin this, and do this:
$this-Widget-read(null, $id);
What has just happened from a SQL perspective? 21 separate SQL
executions? (One for the loop, and 20
On Jan 7, 11:35 pm, Deane [EMAIL PROTECTED] wrote:
Assume this scenario:
I need to retrieve 20 records, and call a method on each of them. So
I do my Find, and get back an array. I then spin this, and do this:
$this-Widget-read(null, $id);
What has just happened from a SQL
Good enough. I'll concede this one, then.
Thanks, everyone, for your input.
Deane
On Jan 7, 5:21 pm, AD7six [EMAIL PROTECTED] wrote:
On Jan 7, 11:35 pm, Deane [EMAIL PROTECTED] wrote:
Assume this scenario:
I need to retrieve 20 records, and call a method on each of them. So
I do my
12 matches
Mail list logo