Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

Ayuda con funciones de una clase

Estas en el tema de Ayuda con funciones de una clase en el foro de Frameworks y PHP orientado a objetos en Foros del Web. buenas: buscando por google encontre una clase que me sirve para lo que estoy intentando hacer para mi pagina de hattrick. Bueno el tema es ...
  #1 (permalink)  
Antiguo 14/06/2007, 22:14
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Ayuda con funciones de una clase

buenas:
buscando por google encontre una clase que me sirve para lo que estoy intentando hacer para mi pagina de hattrick.
Bueno el tema es que pude hacer varias cosas, lo que intento hacer ahora es que me muestre la cantidad de partidos que tiene un equipo, pero no me sale.
La clase usa las siguientes funciones para eso:
parte del archivo htclient.php
Código PHP:
/**
 * Retrieve matches archive for team $id, or for user's own team.
 *
 * @param    string   teamID
 * @access   public
 */
function getMatchesArchiveXML($id false$cup false$first false$last false$season false) {

    
$form = array('outputType' => 'XML');
    if (
$cup)
        
$form['actionType'] = 'viewCup';
    else
        
$form['actionType'] = 'view';
    if (
$id)
        
$form['teamID'] = $id;
    if (
$first)
        
$form['FirstMatchDate'] = $first;
    if (
$last)
        
$form['LastMatchDate'] = $last;
    if (
$season)
        
$form['Season'] = $season;
    
$code $this->http->post(HT_MATCHESARCHIVE$form'http://'.$this->http->host.HT_HOME);
    if (
$code != 200)
        return 
false;
    return 
$this->http->get_response_body();
}

/**
 * Retrieve matches archive for team $id, or for user's own team.
 *
 * @param    string   teamID
 * @access   public
 */
function getMatchesArchive($id false$cup false$first false$last false$season false) {
    if ((! 
$id) && ($this->matchesArchive))
        return 
$this->matchesArchive;
    
$xml $this->getMatchesArchiveXML($id$cup$first$last$count$season);
    if (
$xml) {
        
$parser xml_parser_create();
        
xml_parse_into_struct($parser$xml$vals$index);
        
xml_parser_free($parser);
        if (! 
$vals[$index['FILENAME'][0]]['value'])
            return 
false;
        for (
$i 0$i count($index['MATCHID']); $i++) {
            
$match[$i] = array(
                
'MATCHID' => $vals[$index['MATCHID'][$i]]['value'],
                
'HOMETEAMID' => $vals[$index['HOMETEAMID'][$i]]['value'],
                
'HOMETEAMNAME' => $vals[$index['HOMETEAMNAME'][$i]]['value'],
                
'AWAYTEAMID' => $vals[$index['AWAYTEAMID'][$i]]['value'],
                
'AWAYTEAMNAME' => $vals[$index['AWAYTEAMNAME'][$i]]['value'],
                
'MATCHDATE' => $vals[$index['MATCHDATE'][$i]]['value'],
                
'MATCHTYPE' => $vals[$index['MATCHTYPE'][$i]]['value'],
                
'HOMEGOALS' => $vals[$index['HOMEGOALS'][$i]]['value'],
                
'AWAYGOALS' => $vals[$index['AWAYGOALS'][$i]]['value']
            );
        }
        
$this->matchesArchive = array(
            
'FILENAME' => $vals[$index['FILENAME'][0]]['value'],
            
'VERSION' => $vals[$index['VERSION'][0]]['value'],
            
'USERID' => $vals[$index['USERID'][0]]['value'],
            
'FETCHEDDATE' => $vals[$index['FETCHEDDATE'][0]]['value'],
            
'TEAMID' => $vals[$index['TEAMID'][0]]['value'],
            
'TEAMNAME' => $vals[$index['TEAMNAME'][0]]['value'],
            
'FIRSTMATCHDATE' => $vals[$index['FIRSTMATCHDATE'][0]]['value'],
            
'LASTMATCHDATE' => $vals[$index['LASTMATCHDATE'][0]]['value'],
            
'MATCH' => $match
        
);
        return 
$this->matchesArchive;
    }
    else return 
false;

Yo mirando parte del ejemplo que trae la clase intento esto:
Código PHP:
<?php
require_once 'HTClient.php';

session_start();
if (! 
$_SESSION['htclient']) {
    
header('Location: error.php?code=0');
    exit();
}

// Get the HTClient class instance from session variables.
$htclient $_SESSION['htclient'];

// Get teamDetails.asp XML formation. That should be already in the cache.
$team $htclient->getTeamDetails();
if (! 
$team) {
    
$htclient->logout();
    
header('Location: error.php?code=2');
    exit();
}

//
$partidos $htclient->getMatchesArchive();
if (! 
$partidos) {
    
$htclient->logout();
    
header('Location: error.php?code=2');
    exit();
}

<
p>total partidos: <br /><?php
            
for ($i 0$i<count($partidos['MATCH']); $i++) {
                    
$partidos $partidos['MATCH'][$i];
            echo 
$partidos['MATCHID']; echo '<br />';
            
/*echo htmlentities($partidos['MATCHDATE']); echo '<br />';
            echo htmlentities($partidos['HOMETEAMNAME']); echo '<br />';
            echo htmlentities($partidos['AWAYTEAMNAME']); echo '<br />';
            echo htmlentities($partidos['HOMEGOALS']); echo '<br />';
            echo htmlentities($partidos['AWAYGOALS']); echo '<br />';
            echo '<br />'; */
            
}
            echo 
"hay $i partidos";

?>
Con ese codigo me muestra solo un registro, en vez de 23 que es la cantidad total.
En que le estoy errando?
Espero que me puedan dar una mano.
Desde ya muchas gracias
  #2 (permalink)  
Antiguo 15/06/2007, 07:57
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Ayuda con funciones de una clase

Puedes hacer un var_dump( $partidos ); Para ver el contenido de tu array, asi podras ver la estructura y la forma correcta de ciclarla.

Saludos.
  #3 (permalink)  
Antiguo 15/06/2007, 10:01
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Re: Ayuda con funciones de una clase

pero en toeria estoy haciendo bien el llamado a la funcion?
  #4 (permalink)  
Antiguo 15/06/2007, 10:37
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Ayuda con funciones de una clase

En cuanto a sintaxis si.

Saludos.
  #5 (permalink)  
Antiguo 15/06/2007, 13:13
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 6 meses
Puntos: 43
Re: Ayuda con funciones de una clase

hola GatorV disculpame que te moleste tanto, hice lo que me dijiste y me tiro esto:
Código PHP:
array(9) { ["MATCHID"]=>  string(9"113044646" ["HOMETEAMID"]=>  string(6"331112" ["HOMETEAMNAME"]=>  string(10"CHIPOLA FC" ["AWAYTEAMID"]=>  string(6"217779" ["AWAYTEAMNAME"]=>  string(19"la banda del destor" ["MATCHDATE"]=>  string(19"2007-03-15 01:30:00" ["MATCHTYPE"]=>  string(1"5" ["HOMEGOALS"]=>  string(1"0" ["AWAYGOALS"]=>  string(1"5" 
Por lo que veo solo me tira un partido :s y no entiendo que estoy haciendo mal
  #6 (permalink)  
Antiguo 15/06/2007, 14:17
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Ayuda con funciones de una clase

Por lo que veo deberias de revisar la documentacion de tu sistema, al parecer la funcion solo te regresa un partido.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:57.