i have always used the construct below
if($this->form->isValid()){
$object = $this->form->save();
$id = $object->getId();
}
seeing bindandsave for the first time...
the save function of the form automatically sets the id of the object or in
other words returns the recently saved object.
On Thu, Sep 24, 2009 at 12:48 AM, ferdjuan <[email protected]> wrote:
>
> I have a method which inserts an entry into the database, and I am
> trying to retrieve it's ID immediately so I can return the data back
> to the screen with javascript:
>
> $this->ticketaddform = new TicketForm();
> if ($r->isMethod('post') && $this->ticketaddform->bindAndSave($r-
> >getParameter('ticket')))
> {
> //method is shortened for clarity
> $c = new Criteria();
> $c->addDescendingOrderByColumn(TicketPeer::CREATED_AT);
> $this->newticket = TicketPeer::doSelectOne($c);
> }
>
> After the object is saved and stored via bindAndSave() I run a query
> to grab the most recently created Ticket. Sometimes it gets an older
> ticket, but sometimes it gets the last one. Is there a getLastInsertId
> method, or some other similar technique I can use?
>
> Thanks
>
>
> >
>
--
kind regards
Farrukh K. Muhammad
skype id - mobileweaver
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" 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/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---