Hey all,
using ORM for the first time and I'm having trouble getting my
associations all worked out. Here's a basic overview of my models:
Rentals -> Property with whole bunch of fields
Rates -> Belongs to Rentals
LocationsPage -> Belongs to Rentals
My code looks like this:
<?php
class Rental extends AppModel
{
var $name = 'Rental';
var $hasOne = array(
'Rate' => array(
'className' => 'Rate',
'dependent' => true
),
'LocationsPage' => array(
'className' => 'LocationsPage',
'dependent' => true
)
);
var $belongsTo = array(
'Location' => array(
'className' => 'Location',
'fields' => 'city'
)
);
}
?>
class Rate extends AppModel
{
var $name = 'Rate';
var $belongsTo = 'Rentals';
}
<?php
class LocationsPage extends AppModel
{
var $name = 'LocationsPage';
var $belongsTo = 'Rentals';
}
?>
And my save looks like this:
$this->Rental->saveAll($this->data)
However only data to the Rental table is being saved and not the other
two. Can anyone tell me what I am missing. I don't have a controller
for either Rates or LocationsPages as there are no direct functions to
run against them, does this matter?
Thanks.
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 [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