try with this:

$itemId = $this->getLastInsertID();


--
anl


On Fri, Feb 12, 2010 at 12:07 PM, Jeremy Burns <jeremybu...@me.com> 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to