1 | <?php |
||
9 | class MasterSlavesConnection implements Connection, ConnectionWrapper |
||
10 | { |
||
11 | use ConnectionWrapperTrait; |
||
12 | |||
13 | private $master; |
||
14 | private $slaves; |
||
15 | private $currentConnectionParams; |
||
16 | private $currentSlave; |
||
17 | |||
18 | public function __construct(array $master, array $slaves) |
||
24 | |||
25 | private function checkSlaves(array $slaves) |
||
33 | |||
34 | public function connectToMaster() |
||
40 | |||
41 | public function connectToSlave() |
||
47 | |||
48 | public function isConnectedToMaster() |
||
52 | |||
53 | /** |
||
54 | * @inherit |
||
55 | */ |
||
56 | public function getCurrentConnection() |
||
60 | |||
61 | protected function wrap() |
||
71 | |||
72 | private function chooseASlave() |
||
86 | |||
87 | private function totalSlavesWeight() |
||
95 | |||
96 | public function disableCurrentSlave() |
||
105 | |||
106 | public function slaves() |
||
110 | |||
111 | /** |
||
112 | * Prepares a statement for execution and returns a Statement object. |
||
113 | * |
||
114 | * @param string $prepareString |
||
115 | * |
||
116 | * @return \Doctrine\DBAL\Driver\Statement |
||
117 | */ |
||
118 | public function prepare($prepareString) |
||
123 | |||
124 | /** |
||
125 | * Executes an SQL statement, returning a result set as a Statement object. |
||
126 | * |
||
127 | * @return \Doctrine\DBAL\Driver\Statement |
||
128 | */ |
||
129 | public function query() |
||
133 | |||
134 | /** |
||
135 | * Quotes a string for use in a query. |
||
136 | * |
||
137 | * @param string $input |
||
138 | * @param integer $type |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | public function quote($input, $type = \PDO::PARAM_STR) |
||
146 | |||
147 | /** |
||
148 | * Executes an SQL statement and return the number of affected rows. |
||
149 | * |
||
150 | * @param string $statement |
||
151 | * |
||
152 | * @return integer |
||
153 | */ |
||
154 | public function exec($statement) |
||
159 | |||
160 | /** |
||
161 | * Returns the ID of the last inserted row or sequence value. |
||
162 | * |
||
163 | * @param string|null $name |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | public function lastInsertId($name = null) |
||
171 | |||
172 | /** |
||
173 | * Initiates a transaction. |
||
174 | * |
||
175 | * @return boolean TRUE on success or FALSE on failure. |
||
176 | */ |
||
177 | public function beginTransaction() |
||
182 | |||
183 | /** |
||
184 | * Commits a transaction. |
||
185 | * |
||
186 | * @return boolean TRUE on success or FALSE on failure. |
||
187 | */ |
||
188 | public function commit() |
||
193 | |||
194 | /** |
||
195 | * Rolls back the current transaction, as initiated by beginTransaction(). |
||
196 | * |
||
197 | * @return boolean TRUE on success or FALSE on failure. |
||
198 | */ |
||
199 | public function rollBack() |
||
204 | |||
205 | /** |
||
206 | * Returns the error code associated with the last operation on the database handle. |
||
207 | * |
||
208 | * @return string|null The error code, or null if no operation has been run on the database handle. |
||
209 | */ |
||
210 | public function errorCode() |
||
214 | |||
215 | /** |
||
216 | * Returns extended error information associated with the last operation on the database handle. |
||
217 | * |
||
218 | * @return array |
||
219 | */ |
||
220 | public function errorInfo() |
||
224 | } |
||
225 |