Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Somme sur colonne d'une table 23 Mar 2012 04:40 #1713

  • Johnny
  • Johnny's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 5
  • Thank you received: 0
Bonjour , et bravo pour votre projets Jcook.

J'ai créer un composant et je suis sur le point de le finaliser, mais je bute sur un élement :

dans ma table j'ai une colonne qui comporte des montants et souhaiterait savoir comment faire pour créer le total de cette colonne. ( fonction sum)

Dans l'attente de vous lire
Johnny

Please Log in or Create an account to join the conversation.

Re: Somme sur colonne d'une table 23 Jul 2012 09:44 #2842

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 78
  • Thank you received: 2
dans le model d'une vue collection tu peux utiliser
       	function plouplouf()
	  {    	                                    
	  $user = JFactory::getUser();
	  $userid = $user->id;

	  $params = JComponentHelper::getParams('com_component');
	  $plouf= $params->get('plouf', 1);
		                       
		$database =& JFactory::getDBO()  ;
	 	$database->setQuery( "SELECT SUM(ma-colonne)
					FROM #__batenergie WHERE author='$userid'
					" );
		  if (!$database->query()) {
		    echo $database->stderr();
		    return false;
		  }
	  return $database->loadResult();
	  }
que tu transmets a ton tmpl par le view.html
LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.079 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started