Wednesday, October 27, 2010

Get a model object instead of an array when calling $this->Model->find(id)

Hi everybody

This seems pretty basic, but I just don't get it to work...

I have a model User with a method:

function getIni() {
return "some INI stuff";
}

Then I have an action downloadIni() in UsersController:

function downloadIni() {
// ...
$user = $this->User->find($this->params['named']['user_id']);
$user->getIni();
// ...
}

However, because find() actually doesn't return a User model instance
(but an array), this doesn't work. But sadly I just didn't find a way
to get a model instance from $this->User...

I found this:
http://debuggable.com/posts/how-to-properly-create-a-model-instance-manually:480f4dd6-4424-4c89-9564-4647cbdd56cb
But this seems to be outdated...

Thanks for help!

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

No comments: