1 | <?php |
||
19 | class PDOProvider |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $type; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $dsn; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $username; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $password; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | private $options; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $host; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | private $port; |
||
55 | |||
56 | /** |
||
57 | * @var PDO|null |
||
58 | */ |
||
59 | private $pdo; |
||
60 | |||
61 | const DBMS_POSTGRES = "pgsql"; |
||
62 | const DBMS_MYSQL = "mysql"; |
||
63 | |||
64 | /** |
||
65 | * @param string $dbms database type; one of the DBMS_* class constants |
||
66 | * @param string $dbname name of the database to connect to |
||
67 | * @param string $username |
||
68 | * @param string $password |
||
69 | * @param array $options PDO constructor options |
||
70 | * @param string $host optional hostname; defaults to "localhost" |
||
71 | * @param int|null $port optional port-number; defaults to the standard port-number for the given $db type |
||
72 | */ |
||
73 | 1 | public function __construct($dbms, $dbname, $username, $password, $options = [], $host = 'localhost', $port = null) |
|
96 | |||
97 | /** |
||
98 | * @return PDO |
||
99 | */ |
||
100 | public function getPDO() |
||
108 | |||
109 | /** |
||
110 | * @return string one of the DBMS_* class constants |
||
111 | */ |
||
112 | 1 | public function getDBMS() |
|
116 | |||
117 | /** |
||
118 | * @return string |
||
119 | */ |
||
120 | 1 | public function getDSN() |
|
124 | |||
125 | /** |
||
126 | * @return string |
||
127 | */ |
||
128 | 1 | public function getUsername() |
|
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | 1 | public function getPassword() |
|
140 | |||
141 | /** |
||
142 | * @return array |
||
143 | */ |
||
144 | 1 | public function getOptions() |
|
148 | |||
149 | /** |
||
150 | * @return string |
||
151 | */ |
||
152 | 1 | public function getHost() |
|
156 | |||
157 | /** |
||
158 | * @return string |
||
159 | */ |
||
160 | 1 | public function getPort() |
|
164 | } |
||
165 |