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.077 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started