Page 1 of 1

Spread same value to two tables *not autofill*

Posted: 2018-03-13 13:57
by D Oliveira
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

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

Posted: 2018-03-13 14:42
by D Oliveira
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);

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

Posted: 2018-03-13 15:42
by D Oliveira
*note Table1.field1 and Table.field1 will be an 'id' value

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

Posted: 2018-03-13 18:14
by D Oliveira
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.

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

Posted: 2018-03-21 01:32
by R Tammam
Hello D Oliveira ,
you can check the answer of your question in this thread
https://forums.appgini.com/phpbb/viewto ... f=2&t=2620