Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/09/2013, 17:15
Avatar de adryan310
adryan310
 
Fecha de Ingreso: septiembre-2012
Mensajes: 450
Antigüedad: 11 años, 7 meses
Puntos: 3
Pregunta Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

Hola a todos los del foro...

Tengo el siguiente file de conexion llamado class.connection.php
Código PHP:
class clsConnnection{
    
  public 
$m_connectionDGSDATA null// Conection argument
    
  
public function connection()
  {
        if(!
stristr(PHP_OS'WIN'))
        { 
           
# PRODUCTION LINUX CONNECT ODBC
           
$strUser   "user";        // User
           
$strPass   "xxxx";     // Password
           
$strDB     "Database";  // DB Name
           
$this->m_connectionDGSDATA = new PDO("odbc:$strDB"$strUser$strPass);   
        }else{
               
# PRODUCTION WINDOWS CONNECT PDO 
               
$strServer "172.16.yy.xx"// Server
               
$strUser   "user";        // User
               
$strPass   "xxxx";     // Password
               
$strDB     "Database";  // DB Name
               
$this->m_connectionDGSDATA = new PDO("sqlsrv:Server=" $strServer ";Database=" $strDB$strUser$strPass);
             }
   }
   
   public function 
close(){
       unset(
$this->m_connectionDGSDATA);
   }

Y tengo este file llamado class.search.php
Código PHP:
  require_once('class.connection.php'); // Call file that contain the class connection

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 
loadWebsite(){
      
/* Query to the database that load all the website need for the combobox */
     
$strQuery "SELECT [BackOffice_Dev].[dbo].[book].[id], [BackOffice_Dev].[dbo].[book].[host_name] FROM [BackOffice_Dev].[dbo].[book]";
      
/* Execute the query */
     
$this->strData $this->strConnect->query$strQuery );
      
/* Display record */
     
while($data $this->strData->fetch(PDO::FETCH_ASSOC)){
        
$this->result[] = array('id' => $data['id'],
                                
'host_name' => $data['host_name']);
     }
     
     return 
$this->result;
     
$this->conn->close();
  }

Al ejecutar el archivo index.php que llama a la clase search y la funcion loadWebsite me da el siguiente error:
Cita:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\wamp\www\mas\class\class.connection.php on line 22
PDOException: could not find driver in C:\wamp\www\mas\class\class.connection.php on line 22
Creo que el error es por el driver sqlserver, pero lo tengo habilitado en el php.ini y ademas tengo los dll correspondientes en la carpeta de extensiones php. Los drivers se llaman:
-php_pdo_sqlsrv_54_ts.dll
-php_pdo_sqlsrv_54_nts.dll

Nota: Estoy utilizando WAMP !