Christian, If you're worried about integrity, you may have to resort to using transactions in your db. Consider the InnoDB engine if you're using MySQL.
Also, you would need to implement begin(), commit() and rollback() function for your model: http://bakery.cakephp.org/articles/view/228 You should not encounter issues with using another person's inserted id since the last_insert_id() takes the connection as a parameter and a single connection cannot be used by two users simultaneously (provided you're not doing using a persistent environment connection, which you shouldn't do in the first place). Finally, you can reserve an new id for each request to /persons/add. This way, you are sure that each call to the form generates a unique id. However, this is a complex solution which i know little about. Hope this helps. Dim On Mar 28, 12:48 pm, "christianandradet" <[EMAIL PROTECTED]> wrote: > but if i do it the way you say maybe when two users want to insert a > person at the same time, is it the posibility that the judge gets the > code of another person??, or maybe the tables are locked when > inserting i dont know??? or maybe is there another way to do it?? > Please help me thanks > > > in your afterSave() of the Person model you can do something along > > these lines: > > > if (isset($this->Judge) && !empty($this->data['Judge'])) > > { > > $this->data['Judge']['person_id'] = $this->id; > > $this->Judge->save($this->data); > > > } > > > Dimitry Z. > > > On Mar 26, 12:05 pm, "christianandradet" <[EMAIL PROTECTED]> > > wrote: > > > > hi, > > > i am traing to insert data with a one to one relationship, i am > > > working with this tables: > > > CREATE TABLE 'people` ( > > > `id` smallint(5) unsigned NOT NULL auto_increment, > > > `lastname` varchar(40) NOT NULL, > > > `firstname` varchar(40) NOT NULL, > > > PRIMARY KEY (`id`) ) > > > > CREATE TABLE `judges` ( > > > `person_id` smallint(5) unsigned NOT NULL, > > > `location_id` smallint(5) unsigned NOT NULL, > > > `flavor` enum('USDJ','USMJ') default 'USDJ' ) > > > > in the people controller: > > > var $hasOne = array('judge' => array('className' => 'judge', > > > 'conditions' => '', > > > 'order' => '', > > > 'dependent' => true, > > > 'foreignKey' => > > > 'person_id' > > > ) > > > ); > > > > but i don't know how to insert data in both tables at the same time, > > > how do i configure the add method??? (i can list both tables)- Ocultar > > > texto de la cita - > > > - Mostrar texto de la cita - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
