Spread same value to two tables *not autofill*

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Spread same value to two tables *not autofill*

Post by D Oliveira » 2018-03-13 13:57

How to input the data in a field and once the record is created copy this value and insert it in a different table?

I was thinking 'sql set' in the tablename.php file in the insert function, can someone share a functioning script for this scenario?

Create new record -> table1.field1 = test1 -> hit the create button, then if u query table1.field1 = test1 and query M_Table.field1 = test1

The reason behind it is to create a master hidden table which I can filter and make customized searches since appgini does not support the creation of a view, so this master table would have all the values from all other tables. Example:

Table1.field1 = test1
Table1.field2 = test2
Table1.field3 = test3

Table2.field1 = test4
Table2.field2 = test5

M_Table.field1 = test1
M_Table.field2 = test2
M_Table.field3 = test3
M_Table.field4 = test4
M_Table.field5 = test5

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: Spread same value to two tables *not autofill*

Post by D Oliveira » 2018-03-13 14:42

Also, if I update values in table1 the values from table2 would also be updated, trying something like this...

Code: Select all

$copy_query = '
    UPDATE product_new a
    JOIN   product b ON a.product_id = b.product_id
                    AND b.product_id IN (' . implode(',', $ids) . ')
    SET    a.product_description = b.product_description,
           a.image = b.image';

mysql_query($copy_query);

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: Spread same value to two tables *not autofill*

Post by D Oliveira » 2018-03-13 15:42

*note Table1.field1 and Table.field1 will be an 'id' value

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: Spread same value to two tables *not autofill*

Post by D Oliveira » 2018-03-13 18:14

I am willing to pay $20 through paypal for anyone who can guide me through this whole script that has to work like that:

When I create a new record in table1 it checks the current table id to see if the master table (M_table) has a correspondent id, if it does then the data will be updated and if it doesnt exist its gonna create a record in the table1 and M_table at the same time.

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: Spread same value to two tables *not autofill*

Post by R Tammam » 2018-03-21 01:32

Hello D Oliveira ,
you can check the answer of your question in this thread
https://forums.appgini.com/phpbb/viewto ... f=2&t=2620

Post Reply