Hi bakers,
First, sorry for this newbie question, and second, sorry for my poor
English ;)
I am attempting to insert from a ONE controller data in TWO different
models.
For instance (that is not what i am actually doing, but that is for
sake of simplicity):
I got from my form in a view a MIN value and MAX value, let us say "1"
and "10".
In my controller minmaxs_controller, i do a "$this->Minmax->save($this-
>data);
Ok, thats works (just begin to love cakePHP...)
but just after at the same time, i want in the "delta" table (with my
"Delta" model) insert all the values between this MIN value and the
MAX value so first i create a loop to insert in an array all the
possible values like this:
for($i=$this->data['MinMax']['Min']; $i< $this->data['MinMax']['Man'];
$i++){
array_push($deltaArray, $i);
}
so now i have my array, and i wish to insert all these data in another
table called Delta
So i have first to instance a new Delta Model object in my MinMax
controller:
$this->Delta = new Delta();
and make again a loop to insert my data
foreach ($deltaArray as &$value) {
$this->Delta->save($value);
}
OK, so everything is working, but... i am like feeling not satisfied
by this solution, i am sure it is not elegant and there is probably a
more elegant way of doing for two reasons:
1 - First, i instance another Model (Delta) in a MinMax controller,
and it is confusing and will in the future probably be difficult to
debug
2 - Second, i have to make a loop to insert the array in my model
Delta, maybe CakePHP has kinds of helpers to insert directly a bunch
of values directly and will create all the necessaries needed INSERT.
Thank you very much for your valuable answers.
Greg.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---