Right, but how many inserts does this perform? And does the auto- magic know to use the Exam's newly created id? -seth
On Aug 20, 10:36 am, teknoid <[EMAIL PROTECTED]> wrote: > use saveAll() to store multiple records > > On Aug 20, 12:55 pm, seth <[EMAIL PROTECTED]> wrote: > > > So it seems most implementations of active record I've used have NOT > > had a way to do this, so I guess I'm hoping Cake is above the curve > > here... > > > I'd like the general ability to do N record inserts (and updates) > > without doing N database calls. Essentially, I want something of the > > form: > > > INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); > > > I'd like to do this without writing custom sql. Ideally I'd like to > > do this elegantly with associated models in one save(). If I have a > > Exam model that hasMany Questions, I'd like to do the following: > > > $this->data['Exam']['title'] = 'Midterm Exam'; > > $this->data['Exam']['user_id'] = 'kls93mklj03m9d'; > > $this->data['Question'][0]['question_txt'] = "Question one > > text"; > > $this->data['Question'][1]['question_txt'] = "Question two > > text"; > > $this->Exam->create(); > > $this->Exam->save($this->data); > > > The way I imagine this would work is actually using two inserts, as > > you would need the insert id of Exam to be added to each Question. > > Ok, so clearly this isn't trivial, but it also seems extremely useful. > > Did someone already implement this, or come up with a relatively > > elegant hack? Should I be posting this in the feature request for > > cake instead of here? --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---