Location: PHPKode > projects > Chalange > com_chalange/models/player.php
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.model');
 class ChalangeModelPlayer extends JModel{
 	var $row=null;
 	
 	function getPlayer($id){
 		$query='SELECT * '
 		.'FROM #__gcd_players INNER JOIN #__gcd_categories ON #__gcd_players.idCategory=#__gcd_categories.id '
 		."WHERE #__gcd_players.id=$id";
 		$aux=$this->_getList($query);
 		return $aux[0];
 	}
 	//retorna la lista de dorsales para este corredor en esta competición
 	function getDorsal($playerId, $chalangeId){
 		$query='SELECT dorsal '
 		.'FROM #__gcd_registered INNER JOIN #__gcd_carrerasChalange ON #__gcd_registered.idRace=#__gcd_carrerasChalange.idCarrera '
 		."WHERE #__gcd_carrerasChalange.idChalange=$chalangeId AND #__gcd_registered.idPlayer=$playerId AND dorsal !=0 GROUP BY dorsal";
 		$aux=$this->_getList($query);
 		if (count($aux)>0)	return $aux[0]->dorsal;
 	}
 	
 	function store($post){
   		JTable::addIncludePath(JPATH_COMPONENT.DS.'Tables');
 		$row = JTable::getInstance('Players','Table');
 		$post['birthday']=$post['birthyear']."-".$post['birthmonth']."-".$post['birthday']; 		
  		if (!$row->bind($post)){
  			return JError::raiseWarning(500,$row->getError());
  		}
  		$id=$row->store($post);
  		if ($id==-1){
  			return JError::raiseWarning(500,$row->getError());
  		}
  		return $id;
 	}	
 }
?>
Return current item: Chalange