• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Help in calc element from sql query

aflores

New Member
Hi. I have a sql statement which works as I need in phpMyAdmin but I have no idea how to code it in a calc element. I'm newbie in Fabrik, any suggestion is greatly appreciated.

-- Delete existing temporary table and create a new one from a query:
DROP TABLE IF EXISTS tmp1;
CREATE TABLE IF NOT EXISTS tmp1
SELECT concepto,SUM(importe) AS suma
FROM directo
GROUP BY directo.concepto;

-- Update data from the temporary table to an existing one:
UPDATE conceptos, tmp1
SET conceptos.insumos = tmp1.suma
WHERE conceptos.id = tmp1.concepto;
 
That really doesn't look like the kind of thing you'd want to be doing in a calc element.

What are you actually trying to achieve?

-- hugh
 
Thanks for your fast reply Hugh. You're right this looks messy. Let me try to explain.

What I want is the sum of the element 'importe' from the list 'directo' grouped by the key 'concepto' and then update the element 'insumos' from the list 'conceptos' with this results to their corresponding IDs, but I don't know if it is possible to do in a calc element and how.
 
Anything complex like that, always best to do in a form PHP plugin.

I think you could do that in a single query, no need to use a temporary table, although I can't really help with that in Community support. You could probably get some help with the basic query to use over on stackoverflow.com. Once you have a query that works (test it in phpMyAdmin), we could give you some hints on how to then run it in a submission plugin.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top