y(
>> >>> "Location" => array(
>> >>> "className" => "Location"
>> >>> )
>> >>> )
>> >>> $assoc = "belongsTo"
>> >>> $model = array(
>
->__backAssociation, $this->{$assoc});
> >>> unset ($this->__backAssociation[$model]);
>
> >>> Model::unbindModel() - CORE/cake/libs/model/model.php, line 561
> >>> RentalsController::edit() - APP/controllers/rentals_controller.php, line
unset ($this->__backAssociation[$model]);
>>>
>>> Model::unbindModel() - CORE/cake/libs/model/model.php, line 561
>>> RentalsController::edit() - APP/controllers/rentals_controller.php, line
>>> 91
>>> Object::dispatchMethod() - CORE/cake/libs/ob
4
>> [main] - APP/webroot/index.php, line 88
>>
>> It looks like I still haven't got my head around this ORM thing. Have I
>> set
>> up my associations correctly?
>>
>> Thanks for your help.
>>
> [snip]
>
> Check out the new CakePHP Questi
You probably get the warning due to the following:
[code]
class Rate extends AppModel
{
var $name = 'Rate';
var $belongsTo = 'Rentals';
}
[/code]
Observe that you have given your Rental model as Rentals in the
belongsTo association! Fix that and the warning should go away. Enjoy,
[Rate/s2_week] =>
>>> [Rate/s2_month] =>
>>> [Rate/s3_title] =>
>>> [Rate/s3_day] =>
>>> [Rate/s3_week] =>
>>> [Rate/s3_month] =>
>>>
>> [Rate/s4_month] =>
>> [Rate/extra_info] =>
>> [rental_short_thumb] => holder.gif
>> )
>>
>> )
>>
>>
>>
>> John Andersen-6 wrote:
>>
>> > How does your data look like before the save
Yes, your data is not CakePHP compatible. The Rental looks find, but
it also includes the Rate.
The Rate should be at the same level as Rental, and should look like
this:
[Rate] => Array
(
[0] => Array
(
[title] => 1
[day] =>
...
)
[1] => Ar
lassName'=> 'Rate',
>>'dependent'=> true
>>)
>>);
>>var $belongsTo = array(
>>'Location' => array(
>> 'className' => 'Location',
&g
=> 'city'
>> )
>> );
>>
>> }
>>
>> ?>
>>
>> class Rate extends AppModel
>> {
>> var $name = 'Rate';
>>
>> var $belongsTo = 'Rentals';
>>
>> }
>&
7;className' => 'Location',
>'fields'=> 'city'
>)
>);
>
> }
> ?>
>
> class Rate extends AppModel
> {
> var $name = 'Rate';
>
>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 to the Rate
> table. Can anyone tell me what I am missing. I don't have a contro
to the Rental table is being saved and not to the Rate
table. Can anyone tell me what I am missing. I don't have a controller for
Rates as there are no direct functions to run against them, does this
matter?
Thanks.
--
View this message in context:
http://old.nabble.com/Unable-to-save
On 1/13/2010 4:10 AM, koala kid wrote:
$this->Rental->saveAll($this->data)
http://book.cakephp.org/view/75/Saving-Your-Data
It's all there.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because
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:
array(
15 matches
Mail list logo