try with this:

$itemId = $this->getLastInsertID();


--
anl


On Fri, Feb 12, 2010 at 12:07 PM, Jeremy Burns <[email protected]> wrote:

> I have this function in the items model:
>
> function addNewItem() {
>
>        $this->save();
>
>        $itemId = $this->id;
>
>        return $itemId;
>
> }
>
> When called from a controller it does what it is supposed to do;
> creates a new row in the table and returns the id of the new row.
>
> Here's the odd part; it is creating two rows in the database and
> returning the id of the first row. So if the returned id is 100, I'll
> also find id 101 in the table. Any ideas what might be going wrong?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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