Thursday, May 3, 2012

Re: how to get id before saving

the id is unknown on add.
therefore you should have a afterSave() hook for this

public function afterSave($created) {
    if (!$created) return;
    $this->saveField('personalno', $this->id + 100);
}

or sth like that should work


Am Donnerstag, 3. Mai 2012 12:02:00 UTC+2 schrieb alexkd:
I am using cake1.3
I have a table patient with id(primary key),personalno fields.
I have to set personalno=id+100.
That is before saving, personalno have to id+100. How can i get the id
value beforesaving or aftersaving. If aftersaving then how can i edit
table  with single or more code.

thanks

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: