PHP gets "Class" PDO "not found" message when trying to connect to Oracle DB
I am trying to connect to my oracle database using PDO but I am getting PDO class error. I have verified that PDO is enabled and it looks like this. However, I cannot track down 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 db.
try{
$conn = new PDO("oci:dbname=".$oc_db,$oc_user,$oc_pass);
}catch(PDOException $e){
echo ($e->getMessage());
}
Could there be another reason why I am getting this error? Any help was appreciated.
source to share
This usually means that the PDO extension in question is not compiled or configurable, so PHP can use it. What operating system are you compiling PHP on?
I am not sure if the main PDO module is compiled if you only specify to compile the oracle extension (PDO-OCI).
You should read the PHP manual on 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
source to share
Check my question, I am troubleshooting this and other errors, but then I got stuck, No records found ... Agiletoolkit and Oracle. Grid / CRUD elements
My Oracle connection string in agiletoolkit config-default.php looks like this:
$config['dsn']= array( 'oci:dbname=localhost/MYDATABASE', 'MYUSER', 'MYPASSWORD' );
To fix the driver not found error, I enabled php_pdo_oci8.dll extension in php.ini file from apache installation.
Then there was an error regarding the missing "oci.php" to decide 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 put it in: ... atk4 \ lib \ DB \ dsql
To fix the special characters error from oracle, I set line 59 to / atk 4 / lib / DB / dsql.php for an empty line like this: public $bt='';
I was able to run a database test and it says "Successfully connected to the database".
source to share