Jump to content


Insert data into two tables at the same time

tables multiple insert

  • Please log in to reply
1 reply to this topic

#1 Sebastián

Sebastián

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 07 May 2014 - 12: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
 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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:)







Also tagged with one or more of these keywords: tables, multiple insert

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users