Page 2 of 2
Re: How to update one table using two nurunquery before save
Posted: Mon Apr 22, 2019 2:54 pm
by kev1n
I added a nuDebug($y); to inspect the value of the variable $y. It resolves to
UPDATE kode_barang SET stock_item_kode_barang = '334.0000' WHERE kodebarangid = '5cb81f9800d5f09'
Basically it's trying to set stock_item_kode_barang = '334.0000' (decimal value) but stock_item_kode_barang is of type int(11).
Code: Select all
// Gw coding udah sangat cape, tolong hargai hasil kerja orang
// Hakcipta dan dirancang oleh Yusa Dibrata
$y = "SELECT * FROM raw_material";
$a = nuRunQuery($y);
while($u = db_fetch_object($a)){
$y = "UPDATE kode_barang SET stock_item_kode_barang = '$u->sisa_raw_material' WHERE kode_barang_id = '$u->item_raw_material' ";
nuDebug($y);
nuRunQuery($y);
}
Re: How to update one table using two nurunquery before save
Posted: Tue Apr 23, 2019 3:30 am
by yusa82
kev1n wrote:I added a nuDebug($y); to inspect the value of the variable $y. It resolves to
UPDATE kode_barang SET stock_item_kode_barang = '334.0000' WHERE kodebarangid = '5cb81f9800d5f09'
Basically it's trying to set stock_item_kode_barang = '334.0000' (decimal value) but stock_item_kode_barang is of type int(11).
Code: Select all
// Gw coding udah sangat cape, tolong hargai hasil kerja orang
// Hakcipta dan dirancang oleh Yusa Dibrata
$y = "SELECT * FROM raw_material";
$a = nuRunQuery($y);
while($u = db_fetch_object($a)){
$y = "UPDATE kode_barang SET stock_item_kode_barang = '$u->sisa_raw_material' WHERE kode_barang_id = '$u->item_raw_material' ";
nuDebug($y);
nuRunQuery($y);
}
I already change all the counting form into decimal sir, and still not working sir.
Re: How to update one table using two nurunquery before save
Posted: Tue Apr 23, 2019 7:18 am
by kev1n
Can you upload your db dump again?
Re: How to update one table using two nurunquery before save
Posted: Wed May 01, 2019 4:34 pm
by yusa82
kev1n wrote:Can you upload your db dump again?
Here is the SQL file sir
Re: How to update one table using two nurunquery before save
Posted: Wed May 01, 2019 10:10 pm
by Janusz
Hi,
I modified the code as following and looks that it changes values form both querries.
Code: Select all
// Gw coding udah sangat cape, tolong hargai hasil kerja orang
// Hakcipta dan dirancang oleh Yusa Dibrata
$a = "SELECT item_raw_material, sisa_raw_material FROM raw_material";
$z = nuRunQuery($a);
while($c = db_fetch_object($z)){
$x1=$c->sisa_raw_material;
$x2=$c->item_raw_material;
//nuDebug($x1);
//nuDebug($x2);
$d = "UPDATE kode_barang SET stock_item_kode_barang =". $x1." WHERE kode_barang_id ='". $x2."';";
//nuDebug($d);
nuRunQuery($d);
}
$s = "SELECT * FROM produksi";
$t = nuRunQuery($s);
while($r = db_fetch_object($t)){
$x1=$r->total_stock_produksi;
$x2=$r->barang_yang_di_produksi;
//nuDebug($x1);
//nuDebug($x2);
$s = "UPDATE kode_barang SET stock_item_kode_barang =". $x1." WHERE kodebarangid ='". $x2."';";
//nuDebug($s);
nuRunQuery($s);
}
Re: How to update one table using two nurunquery before save
Posted: Thu May 02, 2019 12:08 am
by Janusz
Additionally please verify consistency of other data. When you generate queries you have the following lines generated from your example PIERCHING 3KG.
Please note that lines 3 and 4 are refering twice to the same id but with 2 different values.
ID 5cb8209bb9ad7a0 (line 6) is not existing in the kode_barang table.
1 [0] : UPDATE kode_barang SET stock_item_kode_barang =0.0000 WHERE kode_barang_id ='5cb81dd2dcfc5f7';
2 [0] : UPDATE kode_barang SET stock_item_kode_barang =156.0000 WHERE kode_barang_id ='5cb81f9802c463b';
3 [0] : UPDATE kode_barang SET stock_item_kode_barang =1894.0000 WHERE kode_barang_id ='5cb8193855ff424';
4 [0] : UPDATE kode_barang SET stock_item_kode_barang =3612.0000 WHERE kode_barang_id ='5cb8193855ff424';
5 [0] : UPDATE kode_barang SET stock_item_kode_barang =1062.0000 WHERE kodebarangid ='5cb81dd2db8f2af';
6 [0] : UPDATE kode_barang SET stock_item_kode_barang =128.0000 WHERE kodebarangid ='5cb8209bb9ad7a0';
7 [0] : UPDATE kode_barang SET stock_item_kode_barang =334.0000 WHERE kodebarangid ='5cb81dd2db8f2af';
8 [0] : UPDATE kode_barang SET stock_item_kode_barang =334.0000 WHERE kodebarangid ='5cb81f9800d5f09';
Re: How to update one table using two nurunquery before save
Posted: Fri May 03, 2019 11:44 pm
by admin
Guys,
I think the problem is that this PHP code should be in After Save not Before Save.
Steven
Re: How to update one table using two nurunquery before save
Posted: Sat May 04, 2019 3:43 am
by yusa82
Janusz wrote:Additionally please verify consistency of other data. When you generate queries you have the following lines generated from your example PIERCHING 3KG.
Please note that lines 3 and 4 are refering twice to the same id but with 2 different values.
ID 5cb8209bb9ad7a0 (line 6) is not existing in the kode_barang table.
1 [0] : UPDATE kode_barang SET stock_item_kode_barang =0.0000 WHERE kode_barang_id ='5cb81dd2dcfc5f7';
2 [0] : UPDATE kode_barang SET stock_item_kode_barang =156.0000 WHERE kode_barang_id ='5cb81f9802c463b';
3 [0] : UPDATE kode_barang SET stock_item_kode_barang =1894.0000 WHERE kode_barang_id ='5cb8193855ff424';
4 [0] : UPDATE kode_barang SET stock_item_kode_barang =3612.0000 WHERE kode_barang_id ='5cb8193855ff424';
5 [0] : UPDATE kode_barang SET stock_item_kode_barang =1062.0000 WHERE kodebarangid ='5cb81dd2db8f2af';
6 [0] : UPDATE kode_barang SET stock_item_kode_barang =128.0000 WHERE kodebarangid ='5cb8209bb9ad7a0';
7 [0] : UPDATE kode_barang SET stock_item_kode_barang =334.0000 WHERE kodebarangid ='5cb81dd2db8f2af';
8 [0] : UPDATE kode_barang SET stock_item_kode_barang =334.0000 WHERE kodebarangid ='5cb81f9800d5f09';
Sir it's a productions Form, that's why it will generate twice or maybe more and it generate according to the production (PRODUKSI) form
Re: How to update one table using two nurunquery before save
Posted: Sat May 04, 2019 3:44 am
by yusa82
admin wrote:Guys,
I think the problem is that this PHP code should be in After Save not Before Save.
Steven
Sir, i already use the AFTER SAVE, and it still not working
Re: How to update one table using two nurunquery before save
Posted: Sat May 04, 2019 9:25 am
by Janusz
Hi, I did following try directly on your application as it was sent and looks that code itself is working proprely. Please verify if you have the same result on your configuration.
Code: Select all
>>>>>>>SET all values=33 to the kode_barang from phpMyAdmin (via SQL) (related to Data Produksi > PIERCHING 3KG)
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kode_barang_id ='5cb81dd2dcfc5f7';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kode_barang_id ='5cb81f9802c463b';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kode_barang_id ='5cb8193855ff424';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kode_barang_id ='5cb8193855ff424';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kodebarangid ='5cb81dd2db8f2af';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kodebarangid ='5cb8209bb9ad7a0';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kodebarangid ='5cb81dd2db8f2af';
UPDATE kode_barang SET stock_item_kode_barang =33 WHERE kodebarangid ='5cb81f9800d5f09';
>>>>>> Check values if updated from phpMyAdmin (all have now value =33)
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb81dd2dcfc5f7';
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb81f9802c463b';
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb8193855ff424';
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb8193855ff424';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb81dd2db8f2af';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb8209bb9ad7a0';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb81dd2db8f2af';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb81f9800d5f09';
==== modify any data from nuBuilder application: Data Produksi > PIERCHING 3KG and SAVE====
>>>>> Check values if updated by phpMyAdmin (all have now values different than 33)
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb81dd2dcfc5f7';
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb81f9802c463b';
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb8193855ff424';
SELECT stock_item_kode_barang FROM kode_barang WHERE kode_barang_id ='5cb8193855ff424';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb81dd2db8f2af';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb8209bb9ad7a0';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb81dd2db8f2af';
SELECT stock_item_kode_barang FROM kode_barang WHERE kodebarangid ='5cb81f9800d5f09';
>>>> so it looks that it behaves properly and changing values from both queries