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

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started