Monday, November 3, 2008

Re: Creating Multiple model objects from the same method

That did the trick, and the magic project_id worked as advertised!

Much Thanks!

for anyone curious of exactly how I fixed my problem, I did the
following in my add() method:

$this->data['Task'][0] = array('name'=>'Wash');
$this->data['Task'][1] = array('name'=>'ClayBar');
$this->data['Task'][2] = array('name'=>'Polish');
$this->data['Task'][3] = array('name'=>'Wax');
if ($this->Project->saveAll($this->data)) {
...do stuff
}
else {
... do other stuff if this fails for whatever reason
}

On Nov 3, 7:15 pm, "spyros k." <SpyrosKalait...@gmail.com> wrote:
> You can use saveAll, at least that's what i've done for something
> similar.
> Here are 2 tutorials on how to do that:
>
> http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part...http://teknoid.wordpress.com/2008/08/04/practical-use-of-saveall-part...
>
> On Nov 4, 1:43 am, Lagg <l.e.wilkow...@gmail.com> wrote:
>
> > I apologize if my subject is confusing and I doubly apologize if this
> > issue has been addressed before.
>
> > I have two tables.
>
> > Projects have many Tasks
>
> > Tasks have 1 project
>
> > I would like set some default Tasks every time I create a new Project.
> > (Such as Clean, Wash, Wax, etc).
>
> > How would I do this? Would I make some sort of model method that does
> > raw sql inserts? Is there a way to do "$this->Project->Task-
>
> > >save( Magic-ProjectID-from-somewhere, "Clean" )  "?
>
> > Thanks for your time.

--~--~---------~--~----~------------~-------~--~----~
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: