My solition is more generic. I know that the object has access to it's values (including the primary key), but you do not neccesarily have the object. You can call the function I wrote anywhere, anytime, and get the current greatest ID.
On Fri, May 21, 2010 at 14:15, Ben Bieker <[email protected]> wrote: > Hi there, > > I'm very new to symfony too but your idea is genereally very bad. So, what > happens if you make a new propel object, fill it with data and do something > like > > $myPropelObject->save(); > > It will get saved into the database. So if it is saved the object should > get the primaryKey Value stored in itself. So why don't you simply retrieve > the value from the object with sth like > $lastInsertedId = $myPropelObject->getPrimaryKey(); > after you just used the save() function? > > This should work? Or am I wrong? > > Greetings > Ben > > On Fri, 21 May 2010 13:04:54 +0200, Gábor Fási <[email protected]> wrote: >> If last means the biggest id, something like this in your peer class > will >> do: >> >> public static function getLastId() >> { >> $c = new Criteria(); >> $c->addDescendingOrderByColumn(self::ID); >> $item = self::doSelectOne($c); >> return $item->getId(); >> } >> > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > 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 > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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
