Re: Using model objects in the controllers

2008-01-07 Thread Deane
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

Re: Using model objects in the controllers

2008-01-07 Thread AD7six
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

Re: Using model objects in the controllers

2008-01-07 Thread Deane
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

Re: Using model objects in the controllers

2008-01-07 Thread the_woodsman
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

Re: Using model objects in the controllers

2008-01-07 Thread Robby Anderson
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 = $this->SomeModel

Re: Using model objects in the controllers

2008-01-07 Thread AD7six
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); $this->Model->f

Re: Using model objects in the controllers

2008-01-07 Thread Deane
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.. >

Re: Using model objects in the controllers

2008-01-07 Thread kristofer
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 PR

Re: Using model objects in the controllers

2008-01-07 Thread Chris Hartjes
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 sc

Re: Using model objects in the controllers

2008-01-07 Thread Deane
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

Re: Using model objects in the controllers

2008-01-07 Thread MrTufty
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 muc