After looking at the link Dr. Tarique Sani posted, try this:
for ( $counter = 0; $counter <= 4; $counter += 1) {
$this->data['Person']['first_name'] = 'First Name ' .
$counter;
$this->data['Person']['last_name'] = 'Last Name ' . $counter;
$this->data['Person']['age'] = 50 + $counter;
$this->Person->create();
$this->Person->save($this->data);
}
On Apr 2, 9:59 pm, behrangsa <[EMAIL PROTECTED]> wrote:
> Hi,
>
> When I execute the following code, only one item gets inserted into the
> people table:
>
> for ( $counter = 0; $counter <= 4; $counter += 1) {
> $this->data['Person']['first_name'] = 'First Name ' . $counter;
> $this->data['Person']['last_name'] = 'Last Name ' . $counter;
> $this->data['Person']['age'] = 50 + $counter;
> $this->Person->save($this->data);
> }
>
> Any ideas why? How can I insert 5 items in a loop like above to the
> database?
>
> Regards,
> Behi
> --
> View this message in
> context:http://www.nabble.com/Saving-in-a-loop-tf3509818.html#a9803735
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---