Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Save into two database name

Questions related to using nuBuilder Forte.
Locked
yusa82
Posts: 19
Joined: Tue Oct 02, 2018 5:29 am

Save into two database name

Unread post by yusa82 »

Hi
How can i save a form into two database in one form,
For example, i create a form with items name (the database table name is items) it contain name and stock, but the stock is readonly with numberformat
and i create a form with stock name (he database table name is stock) it lookup the items name and i can fill the stock there
The question is, how can i save the items database table name and stock database table name in the same time?
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Save into two database name

Unread post by admin »

yusa82,
How can i save a form into two database in one form,
Sorry but I don't understand.

Maybe you could show some screenshots.

Steven
yusa82
Posts: 19
Joined: Tue Oct 02, 2018 5:29 am

Re: Save into two database name

Unread post by yusa82 »

Thank you for the reply
Here is the screenshots
The items form only contain code item, item name and stock(readonly)
The stock form contain date, subform with lookup of the item and contain QTY to update the stock
how can i save and update the total QTY and stock from the different table name
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Save into two database name

Unread post by admin »

yusa82,

You can run PHP to do this after a Form saves.

These might help.

https://wiki.nubuilder.cloud/ ... s#PHP_Code
https://wiki.nubuilder.cloud/ ... Procedures

Steven
yusa82
Posts: 19
Joined: Tue Oct 02, 2018 5:29 am

Re: Save into two database name

Unread post by yusa82 »

wow ok thanks
here is my php code, it might useful if someone want to save into two database in one form

Code: Select all

$y = "update `tabel_b` inner join tabel_a ON tabel_a.tabelnameid = tabel_b.tabelnameid 
set tabel_a.tabelname = tabel_b.tabelname";
$u = nuRunQuery($y);
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Save into two database name

Unread post by admin »

.
yusa82
Posts: 19
Joined: Tue Oct 02, 2018 5:29 am

Re: Save into two database name

Unread post by yusa82 »

ok now im facing new problem...
when i save using the query, the table_a is saving from table_b, but when i try to add another items with the same name, it won't save to the table_a, it keep saving from the first data on table_b, the second or third and more is not updating the table_a

here is the code :

Code: Select all

$y = "update `items` inner join item_stock ON item_stock.items = items.items_id 
set items.item_stock = item_stock.total";
$u = nuRunQuery($y);
The question is, what code should i put to get items.item_stock = item_stock.total?
so that every time i save the form, it will update the items.item_stock.
Please help, im very new with this.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Save into two database name

Unread post by admin »

yusa82,

I would just update the 1 record that needs updating.

Code: Select all

nuRunQuery("UPDATE items SET item_stock = '#total#' WHERE items = '#RECORD_ID#' ");

Steven
yusa82
Posts: 19
Joined: Tue Oct 02, 2018 5:29 am

Re: Save into two database name

Unread post by yusa82 »

Steven,

it works like a charm...
Thank you
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Save into two database name

Unread post by admin »

Cool.
Locked