I am trying to bind it all, but I am having issues with the final dataset. I use a complex query to save data but it looks like nothing gets stored for following association.
-- USER:
public $hasOne = array(
'Profile');
PROFILE:
public $belongsTo = array('User');
$data =
['Model1' =>
['a' => 'a' , 'b'=>'b'], 'User' => ['id' => $this->Auth->user('id'), ], 'Model2' => ['Model2' => ['c' => 'c' ], ],
'Model3' =>
['Model3' =>
['d' => 'd',
'user_id' => $this->Auth->user('id') ], ], 'Model4=>['Model4'=>['f'=>'f']],
'Profile'=>['Profile'=>['user_id'=>$this->Auth->user('id')]]];
pr($data);
$this->Model1->saveAll($data);
Everything is fine except the Profile and User association.
profiles schema:
CREATE TABLE `profiles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) DEFAULT NULL,
`user_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
In the User Model I have only one beforeSave function, which creates a hash for a password, so I think is irrelevant.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment