⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Insert data into two tables at the same time



Sebastián
  • profile picture
  • Member

Posted 07 May 2014 - 00:40 AM

Hi people,

I'm working on a real estate project and I traying to appy an inheritance, saving the common data into the PROPERTY table, and the specific daata into the others tables (HOUSE, APARTMENT, etc) so I have a problem trying to insert data into two different tables at the same time.
 

The tables are Property and House:

Property

  • property_id
  • property_name
  • property_city
  • property_price

House

  • house_id
  • property_id
  • house_bedrooms_qty
  • house_bathrooms_qty

 

I want to view JUST ONE CREATE FORM for these two tables and insert the data into each one.
Is this possible?

Thanks a lot for your help!
Best regards

Sebastian
 


Amit Shah
  • profile picture
  • Member

Posted 07 May 2014 - 05:45 AM

Well yes it is quite possible with 1 single form - you need to use - set_field to set all the fields ... u might need to use change_field_type - to define the field types if required and then add a callback_insert where it will 1st insert data into primary table and then into secondary table.

Have done it the same way for my project and works like a charm

 

Happy GCing:)