Tuesday, February 23, 2010

Re: Another saveAll() problem

You state that

> the associations follow:
>
> Paper hasMany Chart
> Paper hasMany Table
> Paper hasMany Document

Yet your model defines hasOne associations, and all associate to the
same model without any info on their foreign key, conditions etc? You
need to clarify your associations are correct before you attempt to
start saving data.

> class Paper extends AppModel {
>         var $hasOne = array(
>             'Chart' => array(
>                 'className'=>'PaperAttachment'
>             ),
>             'Table' => array(
>                 'className'=>'PaperAttachment'
>             ),
>             'Document' => array(
>                 'className'=>'PaperAttachment'
>             ),
>         );
>
> }

Make sure your debug level is set to 1 or higher and add echo
debug($this->data); into your controller before the save command so
you can copy and paste the structure of your data array. When saving
hasMany data your array needs to be in a specific format to tell Cake
to save multiple rows.

HTH

Paul.

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: