Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/09/2013, 11:57
Avatar de adryan310
adryan310
 
Fecha de Ingreso: septiembre-2012
Mensajes: 450
Antigüedad: 12 años, 6 meses
Puntos: 3
Pregunta Problemas con la siguientes funciones php sqlserver

Hola a todos los del foro...

Tengo la siguiente funcion php que me devuelve los datos de una base de datos sql-server.
Código PHP:
require_once('class.connection.php'); 
class 
search{  
  
  public 
$conn;
  public 
$strConnect;
  public 
$strData;
  public 
$result;
  public 
$intNumRows;
  public 
$CantRows;

  public function 
__construct(){
      
$this->conn = new clsConnnection;
     
$this->conn->connection();
     
$this->strConnect $this->conn->m_connectionDGSDATA;
     
$this->strConnect->setAttributePDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION );
     
$this->result = array();
     
$this->CantRows = array();
  }

  public function 
searchAdvance(){
      
      
$sql "SELECT D.[Description], B.[host_name], P.[IdPlayer], P.[Player], 
                  L.[password], L.[ip_address],L.[login_date],L.[success]
              FROM [BackOffice_Dev].[dbo].[login] L, [BackOffice_Dev].[dbo].[book] B, 
                   [DGSDATA_DEV].[dbo].[BOOK] D, [DGSDATA_DEV].[dbo].[PLAYER] P
              WHERE L.[username] = P.[Player] AND L.[book_id] = P.[IdBook] AND B.[book_id] = D.[IdBook]
                AND L.[book_id] = B.[book_id] AND P.[IdBook] = B.[book_id] ORDER BY B.[book_id]"
;
      
      
$this->strData $this->strConnect->query($sql);
      
$this->intNumRows $this->strData->fetch(PDO::FETCH_NUM);
      
      while(
$data $this->strData->fetch(PDO::FETCH_ASSOC)){
        
$this->result[] = array('Description' => $data['Description'],
                                
'host_name' => $data['host_name'],
                                
'IdPlayer' => $data['IdPlayer'],
                                
'Player' => $data['Player'],
                                
'password' => $data['password'],
                                
'ip_address' => $data['ip_address'],
                                
'login_date' => $data['login_date'],
                                
'success' => $data['success']);  
      }
      
      return 
$this->result;
      
$this->conn->close(); // call the function that close the connection
  
}

   public function 
numRows(){
      
$this->CantRows[] = array($this->intNumRows);
      return 
$this->CantRows;
  }  


Luego en otro archivo presento los datos devueltos por esta clase:
Código PHP:
   include_once('class/class.search.php');
   
   
$Search = new search();
   
$hostName $Search->searchAdvance(); 
   
$intNumRows $Search->numRows();
   
   if(isset(
$hostName) && sizeof($hostName) > ){
       for(
$i=0;$i<sizeof($hostName);$i++){
     echo 
$hostName[$i]['IdPlayer'].'<br>';
         echo 
$hostName[$i]['Description'].'<br>';
         echo 
$hostName[$i]['Player'].'<br>';
     echo 
$hostName[$i]['password'].'<br>';
     echo 
$hostName[$i]['ip_address'].'<br>';
     echo 
$hostName[$i]['login_date'].'<br>';
     echo 
$hostName[$i]['success'].'<br>';
     echo 
$hostName[$i]['host_name'].'<br>';
       }
    
/* HASTA ACA SI ME IMPRIME BIEN LOS DATOS */    
     
}

     echo 
'&nbsp;<li>Rows: '.$intNumRows[0].'</li>'// ACA ES DONDE ME DA ERROR 
El error me da al llamar la funcion que me devuelve la cantidad de filas devueltas por la consulta. Alguna ayuda por favor ?