Foros del Web » Programando para Internet » PHP »

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

Estas en el tema de Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' en el foro de PHP en Foros del Web. 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 ;  ...
  #1 (permalink)  
Antiguo 26/09/2013, 17:15
Avatar de 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 !
  #2 (permalink)  
Antiguo 26/09/2013, 18:03
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Fatal error: Uncaught exception 'PDOException' with message 'could not fin

si ves el phpinfo que te dice del driver??
Código PHP:
Ver original 
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way

Etiquetas: exception, fatal, find, message, select, sql
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 07:03.