How to create action using a multiple query
Posted: Fri Aug 06, 2010 2:11 am
I have xataface last version.
My base includes 3 tables :
*'donateurs' (fields : id,... Vers_10,...).
*'transac10' (fields : ID_Dons10,...MontantDons10,...)
*'donat_dons' (fields : id, ID_Dons10) used in donateurs/relationship.php
Each donateurs(id) may have several records in 'transac10'(ID_Dons10)
I want to calculated the total of all MontantDons10 for each donateur(id) and update the field Vers_10 with this total.
I have tested in PhpMyAdmin with the following query, and it works well :
I want to define an action to update the fields "Vers_10" in the table "donateurs" using the above query, but I hav'nt understand how to do it.
I am newbee with xataface and not able to programm in PHP.
Thank you for help
My base includes 3 tables :
*'donateurs' (fields : id,... Vers_10,...).
*'transac10' (fields : ID_Dons10,...MontantDons10,...)
*'donat_dons' (fields : id, ID_Dons10) used in donateurs/relationship.php
Each donateurs(id) may have several records in 'transac10'(ID_Dons10)
I want to calculated the total of all MontantDons10 for each donateur(id) and update the field Vers_10 with this total.
I have tested in PhpMyAdmin with the following query, and it works well :
- Code: Select all
CREATE OR REPLACE VIEW vue_donsindiv10
AS
SELECT `Nom`,
SUM(`MontantDon10`) AS TotalVerse10, dd.id
FROM `donateurs` AS d
INNER JOIN donat_dons AS dd ON d.id = dd.id
INNER JOIN transac10 AS t ON dd.ID_Dons10 = t.ID_Dons10
WHERE t.`DateDon10`BETWEEN '2009-12-31' AND '2011-01-01'
GROUP BY d.id
ORDER BY TotalVerse10 DESC;
UPDATE donateurs d INNER JOIN vue_donsindiv10 AS v ON d.id=v.id
SET Vers_10= TotalVerse10
WHERE d.id = v.id;
I want to define an action to update the fields "Vers_10" in the table "donateurs" using the above query, but I hav'nt understand how to do it.
I am newbee with xataface and not able to programm in PHP.
Thank you for help