forked from SugiPHP/Database
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDO.php
More file actions
33 lines (30 loc) · 974 Bytes
/
PDO.php
File metadata and controls
33 lines (30 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* @package SugiPHP
* @subpackage Database PDO
* @author Plamen Popov <tzappa@gmail.com>
* @license http://opensource.org/licenses/mit-license.php (MIT License)
*/
namespace SugiPHP\Database;
use PDO as BasePDO;
class PDO extends BasePDO
{
/**
* PDO constructor
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $driver_options
*/
public function __construct($dsn, $username = null, $password = null, array $driver_options = null)
{
parent::__construct($dsn, $username, $password, $driver_options);
// Set error handling to Exception
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch return results as associative array
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
// Use SugiPHP\PDOStatement statements instead of PDOStatement
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array(__NAMESPACE__."\PDOStatement", array()));
}
}