Sorry, read Stephen's first reply without fully reading the OP. You're just trying to save one model row with it's many relations.
Your data array looks correct, so I would suggest there are some validation errors. Try echo debug($this->validationErrors); in your view as it will show you if any of the models failed on save and why. Sorry for above post, Paul @phpMagpie On Sep 5, 11:37 am, WebbedIT <[email protected]> wrote: > Stephen is right, you cannot save Multiple AND Related at the same > time using saveAll in 1.3 > > You would have to foreach() through your array of data and run saveAll > multiple times, ensuring the data for each saveAll() call matched what > was required for saving a single row plus it's related data. > > HTH, Paul > @phpMagpie > > On Sep 3, 6:59 pm, Stephen Latham <[email protected]> wrote: > > > > > > > > > I thought this was possible too with saveall but I had no luck with it. I > > have used saveall but only to save multiple items for a single model. When > > i tried to use it (as you are) to save multiple and associated records > > together it didn't play at all. > > > This is taken directly from the cook book for v1.3: - > > > saveall - "Used to save (a) multiple individual records for a single model > > or (b) this record, as well as all associated records" > > > When i had no luck in doing what you are doing i took that "or" in the above > > to mean it can't do both at the same time. Further on in the page it > > explains saving using keying so i used that method. > > > I would love someone to come on and explain how to use saveall to do both as > > it would be a lot neater than forech loops and keying but i'm not convinced > > it can. > > > Cheers, > > > Steve > > On 3 September 2011 09:18, Dwayne Hanekamp <[email protected]> wrote: > > > > Thanks for all the response! > > > > Teddy, > > > Yes this is a copy of the print_r, though i changed the parameters to > > > make it more clear. > > > Where can i find the sqllog? Is that the sql dump on the bottom? > > > > Stephen, > > > It really is possible, i've seen some tutorials on it. > > > > John, > > > I am not calling model::create() before it > > > Yes, my parentmodel has validation. > > > > Dwayne > > > > On 2 sep, 18:39, John Hardy <[email protected]> wrote: > > > > Are you calling > > > > Model::create() > > > > before you atempt to save the record? > > > > Is your parent model validating? > > > > > I use save all a bunch and make it a habbit of checking these things. > > > > > Saveall works a-ok ;) > > > > > Sent from my iPhone > > > > > On Sep 2, 2011, at 9:29 AM, Stephen Latham <[email protected]> wrote: > > > > > > If you have a read of the manual it says you can either save multiple > > > records of a single model using saveall, or a model and it's associated > > > records. You are trying to do both at once with the save all. That's my > > > understanding of it anyway - I had a similar issue with saveall so ended > > > up > > > just using foreach loops to save the data instead. I have used saveall > > > where I wanted to do one or the other but never both at the same time as > > > you > > > are trying. > > > > > > Cheers Steve. > > > > > > On 2 Sep 2011, at 11:35, Dwayne Hanekamp <[email protected]> > > > wrote: > > > > > >> Hey all, > > > > > >> I'm building an application on which people need to fill in some > > > > >> information and answer some questions. > > > > >> I have two database tables: > > > > >> Applications / Answers, Applications has a 'hasMany'-relationship > > > > >> with > > > > >> Answers. The array coming from my form looks this way: > > > > > >> Array > > > > >> ( > > > > >> [Application] => Array > > > > >> ( > > > > >> [name] => test > > > > >> [email] => [email protected] > > > > >> [name] => test > > > > >> [link] => test > > > > >> ) > > > > > >> [Answer] => Array > > > > >> ( > > > > >> [0] => Array > > > > >> ( > > > > >> [question_id] => 1 > > > > >> [answer] => test > > > > >> ) > > > > > >> [1] => Array > > > > >> ( > > > > >> [question_id] => 2 > > > > >> [answer] => test > > > > >> ) > > > > > >> ) > > > > > >> ) > > > > > >> When i try to do: $this->Application->saveAll($this-data); it simply > > > > >> doesn't work. > > > > > >> Does anyone have an idea? > > > > > >> Thanks in advance! > > > > > >> Dwayne > > > > > >> -- > > > > >> Our newest site for the community: CakePHP Video Tutorialshttp:// > > > tv.cakephp.org > > > > >> Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp > > > others with their CakePHP related questions. > > > > > >> To unsubscribe from this group, send email to > > > > >> [email protected] For more options, visit this > > > group athttp://groups.google.com/group/cake-php > > > > > > -- > > > > > Our newest site for the community: CakePHP Video Tutorialshttp:// > > > tv.cakephp.org > > > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp > > > others with their CakePHP related questions. > > > > > > To unsubscribe from this group, send email to > > > > > [email protected] For more options, visit this > > > group athttp://groups.google.com/group/cake-php > > > > -- > > > Our newest site for the community: CakePHP Video Tutorials > > >http://tv.cakephp.org > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp > > > others with their CakePHP related questions. > > > > To unsubscribe from this group, send email to > > > [email protected] For more options, visit this group > > > athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
