daftfunk Posted September 18, 2012 Posted September 18, 2012 (edited) Je cherche a faire la somme des montants de toutes les commandes d'un client donné... et j'essaye des trucs mais j'arrive pas a sortir ni le code PHP ni le Tpl, mon niveau en POO étant assez limité - si une âme charitable pouvait ma donner et m'expliquez comment ça marche sur ce cas précis Par avance merci de votre sollicitude Edited September 19, 2012 by daftfunk (see edit history) Share this post Link to post Share on other sites More sharing options...
belew Posted September 18, 2012 Posted September 18, 2012 (edited) Essaye avec cette requete : SELECT SUM(`total_paid`) FROM `ps_orders` WHERE `id_customer`= Edited September 18, 2012 by belew (see edit history) Share this post Link to post Share on other sites More sharing options...
daftfunk Posted September 18, 2012 Posted September 18, 2012 Alors ça j'ai déjà essayé ça me renvoi le montant de la dernière commande et pas la somme de toutes les commandes passées pas ce client... :/ Merci quand même Share this post Link to post Share on other sites More sharing options...
belew Posted September 18, 2012 Posted September 18, 2012 J'avais oublier le SUM dans la requete sorry Share this post Link to post Share on other sites More sharing options...
daftfunk Posted September 18, 2012 Posted September 18, 2012 (edited) Genre $total = Db::getInstance()->getRow(' SELECT [color=#343943][font=Arial, Helvetica, sans-serif][size=3]SUM([/size][/font][/color]`total_paid`) FROM `'._DB_PREFIX_.'orders` WHERE `id_customer` = \''.pSQL($cookie->id_customer).'\''); $smarty->assign('total',$total); Mais ça me renvoi quand je l'appelle ds le tpl "Array" .... question comment je récupère la valeur? Edited September 18, 2012 by daftfunk (see edit history) Share this post Link to post Share on other sites More sharing options...
J. Danse Posted September 18, 2012 Posted September 18, 2012 getValue au lien de getRow Share this post Link to post Share on other sites More sharing options...
belew Posted September 18, 2012 Posted September 18, 2012 +1 Share this post Link to post Share on other sites More sharing options...
daftfunk Posted September 18, 2012 Posted September 18, 2012 Je suis embêté avec ce code Il y rien qui sort $total = Db::getInstance()->getValue(' SELECT SUM(`total_paid`) FROM `'._DB_PREFIX_.'orders` WHERE `id_customer` = \''.pSQL($cookie->id_customer).'\''); $smarty->assign('total',$total); Share this post Link to post Share on other sites More sharing options...
J. Danse Posted September 18, 2012 Posted September 18, 2012 $total = Db::getInstance()->getValue(' SELECT SUM(`total_paid`) as nb FROM `'._DB_PREFIX_.'orders` WHERE `id_customer` = \''.(int)$cookie->id_customer)'\''); $smarty->assign('total',$total); Share this post Link to post Share on other sites More sharing options...
daftfunk Posted September 18, 2012 Posted September 18, 2012 Toujours rien Tu l'ouvres quand la parenthese WHERE `id_customer` = \''.(int)$cookie->id_customer)'\''); WHERE `id_customer` = \''.(int)($cookie->id_customer)'\'');? j'ai fait moulte combinaisons toujours pas de sortie Share this post Link to post Share on other sites More sharing options...
daftfunk Posted September 19, 2012 Posted September 19, 2012 Plus de succès avec $total = Db::getInstance()->getValue(' SELECT SUM(`total_paid`) FROM `'._DB_PREFIX_.'orders` WHERE `id_customer` = \''.pSQL($cookie->id_customer).'\''); $smarty->assign('total',$total); Merci de votre aide Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now