public function __construct($dsn, $username = null, $password = null, array $options = null) { register_shutdown_function(array($this, '__destruct')); // Ensure the DB is always cleaned up. -- cwells if (!isset($this->logger)) { // Override by setting in a subclass. --cwells $this->logger = Logger::getLogger(\CWA\Util\LOG_NAME); } $this->dsn = $dsn; $this->username = $username; $this->password = $password; $this->options = $options; try { $this->handle = new PDO($this->dsn, $this->username, $this->password, $this->options); $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { $this->setLastError($e); } }
public function getLogger($name) { return \CWA\Util\Logger::getLogger($name); }