1 | <?php |
||
21 | abstract class AbstractPDOConnection |
||
22 | { |
||
23 | const DRIVER = 'driver'; |
||
24 | const DATABASE = 'database'; |
||
25 | const SOCKET = 'socket'; |
||
26 | const USER = 'user'; |
||
27 | const PASSWORD = 'password'; |
||
28 | const DRIVER_OPTIONS = 'options'; |
||
29 | |||
30 | /** |
||
31 | * For MySql |
||
32 | */ |
||
33 | const HOST = 'host'; |
||
34 | const PORT = 'port'; |
||
35 | const DB_NAME = 'dbname'; |
||
36 | const UNIX_SOCKET = 'unix_socket'; |
||
37 | const CHARSET = 'charset'; |
||
38 | |||
39 | /** |
||
40 | * For Sqlite |
||
41 | */ |
||
42 | const PATH = 'path'; |
||
43 | const MEMORY = 'memory'; |
||
44 | |||
45 | /** |
||
46 | * @var PDO |
||
47 | */ |
||
48 | protected $connection; |
||
49 | |||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $keys = []; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $dsn = ''; |
||
59 | |||
60 | /** |
||
61 | * Attempts to create a connection with the database. |
||
62 | * |
||
63 | * @param array $parameters All connection parameters passed by the user. |
||
64 | * @param string|null $username The username to use when connecting. |
||
65 | * @param string|null $password The password to use when connecting. |
||
66 | * @param array $driverOptions The driver options to use when connecting. |
||
67 | * |
||
68 | * @throws InvalidArgumentException |
||
69 | */ |
||
70 | public function __construct(array $parameters, $username = null, $password = null, array $driverOptions = []) |
||
88 | |||
89 | /** |
||
90 | * @return PDO |
||
91 | * @codeCoverageIgnore |
||
92 | */ |
||
93 | public function getConnection() |
||
97 | |||
98 | /** |
||
99 | * @param array $parameters |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | protected function buildDSNString(array &$parameters) |
||
114 | } |
||
115 |