i have a simple form with two input fields and i would like to save the data from one field inside one table and the other one inside the second table.
to save the data i use $this->Room->save($this->data)
any ideas how this can be done?
thanks
edit:
one is rooms
the other one is roomates
the common key i want to use is is id_rooms
and id_roomates
For Room
build an array like below. It is just an example, set it according to your actual fields.
$this->data['Room']['id_rooms'] = $this->data['Room']['id']
$this->data['Room']['abc'] = $this->data['Room']['xyz']
Then save data to room table: $this->Room->save($this->data)
.
Next build an array for second table, say Roomtitle
, as below:
$this->data['Roomtitle']['id_rooms'] = $this->data['Room']['id']
$this->data['Roomtitle']['abc'] = $this->data['Room']['xyz']
and save it: $this->Roomtitle->save($this->data)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.