ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

DB Save several rows

Zyraj 03 Aug, 2017
Hi, I've been reading a lot and searching in the forums but I just can't get to a solution, so I'm needing some help, this is the deal...
I need to UPDATE 4 rows at the same time in the same table, I know this can be achieved by using 4 "Save Data" functions in the submit event, but, while this would work, it would create some consistency problems later, so It would be MUCH better to find a "one function" solution, furthermore the value to UPDATE in each row is only one, based on (WHERE) 'user_id' and 'field_id' (which could be one of four options: 1, 2, 3, 4)

Beats me, any ideas?
Max_admin 03 Aug, 2017
Hi Zyraj,

You can use a "Loop event" function and inside it a "Save data" function, you will need to set the "data providers" correctly for this to work.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Zyraj 03 Aug, 2017
Hi Max, thanks for your answer!!

But the four options being 1, 2, 3, 4 was random, lets say they are cat, dog, goat and bee, the DB was designed this way by someone else and I can't modify it at this point, any ideas?
Max_admin 04 Aug, 2017
Hi Zyraj,

This does not matter, your "Loop" data provider should point to the variable holding the 4 options, then your "save data" inside the loop can use the {var:loop_name.row} in the update syntax.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Zyraj 04 Aug, 2017
Hey Max! Thanks for your answer! I will give it a try!!


Chris
Zyraj 04 Aug, 2017
Hi again!! Just realized about something, on one hand the data provider holds a lot of information besides the variables (I know this could be fixed), and on the other hand the loop would trigger 4 success events, I actually need this event to proceed with the next operations, that's the whole point of using one single function, so this would be a problem...
Max_admin 05 Aug, 2017
Hi Zyraj,

You want to run some action between 1 to 4 times, then you need a loop, and if you want to abort any of the 4 updates then do that in the "save data" update conditions, if the condition is not met then no update will occur

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Zyraj 08 Aug, 2017
Hi Max, thanks again for your answer, but the point is not that I need to abort, but I need to combine the 4 UPDATEs into 1 operation, to me the loop is exactly the same as placing one after the other, and I even have more control of the functions that way, I guess there's no way around, anyway thanks for your help!!!
On another topic that's bugging me if I may ask right here... is there a way to set "ON DUPLICATE KEY UPDATE" on the INSERT query?


Chris
Max_admin 09 Aug, 2017
Hi Zyraj,

You need to update 4 rows with 1 update statement ? if this can be done using normal SQL then it will work using a single "Save data" call, otherwise you need a loop.

You can not use "on duplicate key update" feature, at least for now, you will need a custom SQL statement for this, but I have added it to the todo list.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Zyraj 09 Aug, 2017
1 Likes
Hey again Max, Thanks a lot for your time and answers!
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com