$this->model_name->id is according to the API: * Value of the primary key ID of the record that this model is currently pointing to. * Automatically set after database insertions. So that may or may not be the last inserted record
$this->model_name->getLastInsertId(); appears to do exactly what it says, get the last inserted id. Looking at the Model class, getLastInsterId() fetches a private property of the class, not the property id. Regards, Don On May 8, 4:24 am, "CakePHP.Saint" <[email protected]> wrote: > Hi Can any one please say the differences between them > After i inserting a record I can use following ways to get the last > insert id . > I need to know whats the diff between them. Which is best ? > > $this->model_name->getLastInsertId(); > $this->model_name->id; > > Thanks in advance -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
