⚠ 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

How to insert in 2 tables at the same time



dev.mwh

dev.mwh
  • profile picture
  • Member

Posted 02 April 2012 - 21:05 PM

Hello!

I have 3 tables:

language_id:[list]
[*]id
[*]code
[*]description
[/list]

article: [list]
[*]id
[*]parent_id
[/list]

article_translation:[list]
[*]id
[*]article_id
[*]language_id
[*]description
[/list]

I want to insert an article and his translation.

how to pass the language id to add form,
and how to insert data in article then in article_translation?

thanks,

dev.mwh

dev.mwh
  • profile picture
  • Member

Posted 03 April 2012 - 22:21 PM

I found the solution for the first part here:
/topic/53-insert-operations-on-model-with-set-relation-where/

I use function: "change_field_type"

$crud->change_field_type('language_id', 'hidden', $lang);

mgr_metal

mgr_metal
  • profile picture
  • Member

Posted 16 May 2012 - 12:06 PM

I am interested in that question too. I would like to know how can I add new record thats affect two tables at once?
category table:
id_cat
ordr
level

second table category_info:
id
id_cat
name
desc

relation is 1-n on id_cat

sbosx

sbosx
  • profile picture
  • Member

Posted 08 June 2012 - 14:14 PM

I am intrested too in learning that.

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 09 June 2012 - 16:15 PM

Well to add at once two tables into the add/edit form is the set_relation_1_1 that I want to add at a future release. For now I don't have any example to give you. As for the multilingual perhaps something like this would help you:
/topic/527-multilanguage-solution-crud/page__p__2059#entry2059

h4kl0rd

h4kl0rd
  • profile picture
  • Member

Posted 10 October 2013 - 09:47 AM

Hey @web-johnny, wanted to know the progress on the integration of set_relation_1_1 for the new release.

I'm currently using the latest release of Grocery CRUD (version 1.4.1).

 

So, I'm working on a project that includes Sales Module, the user enters sales details and after the sales have been saved it has to automatically calculate if there was profit or loss. If profit enters details to Profits Table (has field 'profit_made'), if loss was incurred during the sale, then the record has to be entered to the Loss Table (has field 'loss_incurred').

 

How should I implement this in my project?