1 | <?php |
||
11 | class Connection |
||
12 | { |
||
13 | const DSN_MYSQL = 'mysql:host=%s;port=%d;dbname=%s;charset=utf8'; |
||
14 | const DSN_SQLITE = 'sqlite:%s'; |
||
15 | |||
16 | /** @var string */ |
||
17 | private $user; |
||
18 | |||
19 | /** @var string */ |
||
20 | private $password; |
||
21 | |||
22 | /** @var PDO */ |
||
23 | private $currentConnection; |
||
24 | |||
25 | /** @var string */ |
||
26 | private $provisioningTable; |
||
27 | |||
28 | /** @var string */ |
||
29 | private $criteriaColumn; |
||
30 | |||
31 | /** @var string */ |
||
32 | private $dsn; |
||
33 | |||
34 | /** @var ConnectionFactoryInterface */ |
||
35 | private $connectionFactory; |
||
36 | |||
37 | |||
38 | |||
39 | /** |
||
40 | * @param ConnectionFactoryInterface $connectionFactory |
||
41 | */ |
||
42 | 3 | public function __construct(ConnectionFactoryInterface $connectionFactory) |
|
46 | |||
47 | |||
48 | |||
49 | /** |
||
50 | * @param string $databaseName |
||
51 | * @return $this |
||
52 | */ |
||
53 | 1 | public function useSqlite($databaseName = ':memory:') |
|
59 | |||
60 | |||
61 | |||
62 | /** |
||
63 | * @param string $host |
||
64 | * @param integer $port |
||
65 | * @param string $databaseName |
||
66 | * @param string $databaseUser |
||
67 | * @param string $databasePassword |
||
68 | * @return $this |
||
69 | */ |
||
70 | 1 | public function useMysql($host, $port, $databaseName, $databaseUser, $databasePassword) |
|
78 | |||
79 | /** |
||
80 | * @return PDO |
||
81 | */ |
||
82 | 2 | public function getCurrentConnection() |
|
90 | |||
91 | |||
92 | |||
93 | /** |
||
94 | * @param string $provisioningTable |
||
95 | * @return $this |
||
96 | */ |
||
97 | 2 | public function setProvisioningTable($provisioningTable) |
|
103 | |||
104 | |||
105 | |||
106 | /** |
||
107 | * @param string $criteriaColumn |
||
108 | * @return $this |
||
109 | */ |
||
110 | 2 | public function setCriteriaColumn($criteriaColumn) |
|
116 | |||
117 | |||
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getProvisioningTable() |
||
126 | |||
127 | |||
128 | |||
129 | /** |
||
130 | * @return string |
||
131 | */ |
||
132 | public function getCriteriaColumn() |
||
136 | |||
137 | |||
138 | |||
139 | public function getDatabaseName(): string |
||
143 | } |
||
144 |