1 | <?php |
||
10 | class PDODatabase extends AbstractSQLDatabase |
||
11 | { |
||
12 | |||
13 | 14 | private static function bindToStatement(PDOStatement $stmt, array $bindVariables) |
|
28 | |||
29 | private $connection; |
||
30 | private $dsn; |
||
31 | private $username; |
||
32 | private $password; |
||
33 | private $options; |
||
34 | private $defaults = [ |
||
35 | PDO::ATTR_STRINGIFY_FETCHES => true |
||
36 | ]; |
||
37 | |||
38 | 24 | /** |
|
39 | * Creates a new PDODatabase with the "Data Source Name", username, password, and extra options. |
||
40 | 24 | * |
|
41 | 24 | * The arguments MUST be compatiable with the PDO constructor. |
|
42 | 24 | * |
|
43 | 24 | * @param string $dsn |
|
44 | 24 | * @param string|null $username |
|
45 | 24 | * @param string|null $password |
|
46 | * @param array $options |
||
47 | */ |
||
48 | public function __construct($dsn, $username = null, $password = null, array $options = []) |
||
56 | |||
57 | /** |
||
58 | * @return PDO|null |
||
59 | */ |
||
60 | 19 | public function getConnection() |
|
66 | |||
67 | 2 | /** |
|
68 | 2 | * Gets the connection string for PDO. |
|
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | public function getConnectionString() |
||
76 | |||
77 | /** |
||
78 | 1 | * Returns the username for PDO. |
|
79 | * |
||
80 | 1 | * @return string|null |
|
81 | 1 | */ |
|
82 | public function getUsername() |
||
86 | 19 | ||
87 | /** |
||
88 | 19 | * Returns the password for PDO. |
|
89 | * |
||
90 | * @return string|null |
||
91 | 1 | */ |
|
92 | public function getPassword() |
||
96 | |||
97 | /** |
||
98 | * @return array |
||
99 | 17 | */ |
|
100 | public function getOptions() |
||
104 | |||
105 | /** |
||
106 | * @return integer |
||
107 | 2 | */ |
|
108 | public function lastIdCreated() |
||
113 | |||
114 | 1 | /** |
|
115 | 1 | * @param SqlStatementBuilder $statement |
|
116 | * @param array $options |
||
117 | * @param bool $returnResult |
||
118 | * @return array[]|null |
||
119 | * |
||
120 | 1 | * @throws DatabaseException If there was an error connecting to the database. |
|
121 | */ |
||
122 | 1 | protected function sendQueryToDatabase(SqlStatementBuilder $statement, array $options, $returnResult) |
|
165 | |||
166 | private function initalizeConnection() |
||
187 | } |
||
188 |