Hello,
I have read the article by Mark Story:
http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-sites-with-fat-models
So now I want to use that. In some cases it works already very fine, but I am
not sure if I can place an method in my model (which ist growing fatter day by
day *g*) when it calls information from another model. (I use Cakephp 1.2 RC3)
E.g.:
My Model Hotelinfo belongsTo Hotel and Hotelinfomaster.
Now in my controller hotels_controller.php I have a function where when a hotel
is added also a connected table entry of hotelinfo is added by getting the data
from the Hotelinfomaster.
At the moment I do it this way:
$this->data =
$this->Hotel->requestAction('hotelinfos/add/'.$hotelmaster_id.'/'.$this->Hotel->id);
That calls this funtion in hotelinfos_controller.php:
function add($hotelmaster_id = null, $hotel_id = null) {
if ($hotelmaster_id != null) {
$this->Hotelinfo->create();
//get data from Masterobject 'Hotelinfomaster'
$this->data =
$this->Hotelinfo->requestAction('hotelinfomasters/getHotelinfomaster/'.$hotelmaster_id);
//do some data processing magic
if ($this->Hotelinfo->save($this->data['Hotelinfo'])) {
/*$this->Session->setFlash(__('The Hotelinfo wurde gespeichert', true));
$this->redirect(array('action'=>'../hotels/edit/'.$hotelmaster_id));*/
} else {
$this->Session->setFlash(__('The Hotelinfo konnte nicht gespeichert
werden. Bitte überprüfen Sie die Angaben.', true));
}
}
}
As you can see my function gets data from another model 'Hotelinfomaster'. Can
I place such a function in my model hoteilinfo.php? If yes what would be the
syntax to get the data from Hotelinfomaster?
Thank you
Anja
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---