I'm pretty new in Doctrine and i've a problem. I install Doctrine 2 with CodeIgniter. Here is my class to call Doctrine in CodeIgniter:
<?php
use Doctrine\Common\ClassLoader;
class Doctrine
{
public $conn;
public function __construct()
{
try
{
require_once APPPATH . '/third_party/Doctrine/Common/ClassLoader.php';
$classLoader = new ClassLoader('Doctrine', APPPATH . 'third_party' );
$classLoader->register();
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => 'mydb',
'user' => 'user',
'password' => 'secret',
'host' => 'localhost',
'driver' => 'pdo_mysql'
);
$this->conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\PDOException $e){
echo 'An error as ocurred...';
} catch (Exception $ex) {
echo 'ERROR';
}
}
The config parameters are wrong, with the porpose to throw an excpetion, in this case a PDOException
. But to my surprise, insted I get the message
"An error as ocurred..." i get "Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'user'(...)"
I try the catch with \PDOException
or PDOException
and can't catch the exception....
Can someone help me?