Re: Internal Server Error
Ok, I found the problem.
Before telling you what was the problem, let me ask you something...
can I create a function called "find" in the model?
As soon as I removed this function from the model Companies,
everything was ok.
Thanks for your help :)
On 10 out, 02:11, brian <bally.z...@gmail.com> wrote:
> Normally, with CakePHP, you have a controller for each model. That's
> not set in stone, of course, but if you have a CompaniesController, it
> should automatically have access to a Company model. Hence, you can
> simply do $this->Company->whatever(). Perhaps there's some issue
> you've uncovered where using ClassRegistry::init('SomeModel') fails
> when in the controller for omeModel. Maybe it's a bug, I don't know.
> But it doesn't seem to me to be a very serious problem when the
> correct usage would be to access the model directly.
>
> In any case, did you actually try what I suggested? If it still fails
> when using $this->Company->... then you can start looking elsewhere
> for the problem.
>
> On Fri, Oct 9, 2009 at 3:38 PM, rlcabral <ricardolcab...@gmail.com> wrote:
>
> > The connection with the DB is supposed to be done by the model, not by
> > the controller. But it does not matter here.
>
> > Using the model or the controller, it does not work as expected.
>
> > On 9 out, 17:56, brian <bally.z...@gmail.com> wrote:
> >> Why use ClassRegistry::init() if this code is in your
> >> CompaniesController? You should be able to just do:
>
> >> $this->set('companies', $this->Company->getAll());
>
> >> Come to that, why even have a getAll() method?
>
> >> $this->set('companies', $this->Company->find('all'));
>
> >> On Fri, Oct 9, 2009 at 12:52 PM, rlcabral <ricardolcab...@gmail.com> wrote:
>
> >> > Yes, I was referring to the model names.
>
> >> > Right now the code is really simple because I'm trying to figure out
> >> > what is the problem.
>
> >> > #app/controllers/companies_controller.php
> >> > function admin_search() {
> >> > $companies = ClassRegistry::init('Company')->getall();
> >> > $this->set('companies', $companies);
> >> > }
>
> >> > and the "getall" function in the model Company is:
>
> >> > #app/models/company
> >> > function getall() {
> >> > return $this->find('all');
> >> > }
>
> >> > Pretty basic, but does not work. However, If I change Company to City
> >> > or any other model, it works.
>
> >> > I don't wanna find all, but for now I'm doing this to see where the
> >> > problem is. Later I will put the term that I wanna search for.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home