On Thu, Oct 7, 2010 at 4:12 PM, DerBjörn <[email protected]> wrote: > Hi, > > i created a data array including 4 models: player, skillpool (hasOne), > strokepool (hasOne) and club (hasAndBelongsToMany): > > Array > ( > [Player] => Array > ( > [name] => John > ) > > [SkillPool] => Array > ( > [stamina] => 9.9878 > ) > > [StrokePool] => Array > ( > [stroke0_00] => 1.0626 > ) > > [Clubs] => Array > ( > [id] => 1 > ) > > ) > > To save now all together i use $this->Player->saveAll($this->data); > and it works perfectly. > > Now i would like to add more players at once and put everything in a > loop, so the data array looks like: > > Array > ( > [0] => Array > ( > [Player] => Array > ( > [name] => John > ) > > [SkillPool] => Array > ( > [stamina] => 9.6516 > ) > > [StrokePool] => Array > ( > [stroke0_00] => 3.9151 > ) > > [Clubs] => Array > ( > [id] => 1 > ) > ) > > [1] => Array( > ... > ) > ) > > Problem: The only datasets which get added now are Player and Club, > SkillPool and StrokePool (both hasOne with Player) get completely > ignored.
Normally, when saving records in a loop, one should call $this->model->create(). I'm not sure that the failure of the associations to save is related but it's worth trying a $this->Player->create() before the saveAll(). 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
