In PHP getting “Class 'PDO' not found” error while trying to connect to Oracle DB

StackOverflow https://stackoverflow.com/questions/1436264

  •  07-07-2019
  •  | 
  •  

Question

I am trying to connect to my oracle database using PDO but I am getting Class PDO not found error. I have checked that PDO is enabled and it appears so. Still I am not able to trace why I am getting this error. Here is my configure command,

cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" 
"--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" 
"--with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build" 
"--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" 
"--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared"

PHP ver : 5.2.8 Oracle: 10.2

This is the code I am using to connect to the db.

try{
    $conn = new PDO("oci:dbname=".$oc_db,$oc_user,$oc_pass);
}catch(PDOException $e){
    echo ($e->getMessage());
}

Can there be any other reason that I am getting this error? Any help appreciated.

Was it helpful?

Solution

This generally means the PDO extension in question isn't compiled and set up so PHP can use it. What operating system are you compiling PHP on?

I'm not sure if PDO core module is compiled if you only specify to compile the oracle extension of it (PDO-OCI).

You should check out the PHP manual regarding how to install and enable the PDO module.

You should look at these sites: http://is.php.net/manual/en/pdo.installation.php http://is.php.net/manual/en/ref.pdo-oci.php

OTHER TIPS

Check my question I troubleshoot this and other errors but then Im stuck, No records found ...Agiletoolkit and Oracle. Grid/CRUD elements

My Oracle connection string in agiletoolkit config-default.php file looks like this:

$config['dsn']= array( 'oci:dbname=localhost/MYDATABASE', 'MYUSER', 'MYPASSWORD' );

To fix the driver not found error, I enabled extension=php_pdo_oci8.dll in the php.ini file from my apache installation.

Then there was an error about a missing "oci.php", to solve that I had to create my own file like this:

class DB_dsql_oci extends DB_dsql {
    function limit($cnt,$shift=0){
        $cnt+=$shift;

    $this->where('NUM_ROWS>=',$shift);
        $this->where('NUM_ROWS<',$cnt);
        return $this;
    }
    function render_limit(){
        return '';
    }
}

and placed it at: ...atk4\lib\DB\dsql

To fix the special chars error from oracle , I set line 59 on /atk4/lib/DB/dsql.php to empty string like this: public $bt='';

I manage to run the database test, and it says "Successfully connected to database."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top