I answer myself after a trip on Irc channel (thnk's to Gwoo and
Daanz):

1) $this->getID() and $this->getLastInsertID() are deprecated for a
long time, but it is not indicated in the source code
2) we must use $this->id() instead
3) in a loop, we must call $this->create() before $this->save()

Hope this helps and understandable!



On 21 mai, 16:31, avairet <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm surprised by $this->getID() behavior when I call $this->save() in
> a loop...
> Actually, $this->getID() returns always the same number!?
>
> My code:
>
> for ($i=1;$i<=$max;$i++) {
>     $new_tag = array('name'=>$data['Item']['Tag'.$i], 'slug'=>$slug,
> 'insertion'=>1);
>     $this->save($new_tag,false);
>     $new_id = $this->getID();
>     echo "new_id : ".$new_id."<br />";
>
> }
>
> For each loop step, "new_id" is always the first new id...
> Of course, all my save's calls are Mysql "INSERT", not UPDATE...
>
> Any idea?
>
> I'm using Cake 1.2 nightly builds.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to