1 | <?php |
||
9 | class MasterSlavesConnection implements Connection, ConnectionWrapper |
||
10 | { |
||
11 | private $master; |
||
12 | private $slavesWeights; |
||
13 | private $connection; |
||
14 | private $driver; |
||
15 | private $currentConnectionFactory; |
||
16 | |||
17 | public function __construct($master, SplObjectStorage $slavesWeights) |
||
23 | |||
24 | private function checkSlavesWeights(SplObjectStorage $slavesWeights) |
||
32 | |||
33 | public function connectToMaster() |
||
38 | |||
39 | public function connectToSlave() |
||
44 | |||
45 | public function isConnectedToMaster() |
||
49 | |||
50 | private function connection() |
||
57 | |||
58 | public function getCurrentConnection() |
||
62 | |||
63 | public function wrappedConnection() |
||
70 | |||
71 | public function wrappedDriver() |
||
78 | |||
79 | private function wrap() |
||
89 | |||
90 | private function chooseASlave() |
||
104 | |||
105 | private function totalSlavesWeight() |
||
113 | |||
114 | public function disableCurrentSlave() |
||
120 | |||
121 | public function slaves() |
||
125 | |||
126 | /** |
||
127 | * Prepares a statement for execution and returns a Statement object. |
||
128 | * |
||
129 | * @param string $prepareString |
||
130 | * |
||
131 | * @return \Doctrine\DBAL\Driver\Statement |
||
132 | */ |
||
133 | public function prepare($prepareString) |
||
138 | |||
139 | /** |
||
140 | * Executes an SQL statement, returning a result set as a Statement object. |
||
141 | * |
||
142 | * @return \Doctrine\DBAL\Driver\Statement |
||
143 | */ |
||
144 | public function query() |
||
148 | |||
149 | /** |
||
150 | * Quotes a string for use in a query. |
||
151 | * |
||
152 | * @param string $input |
||
153 | * @param integer $type |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | public function quote($input, $type = \PDO::PARAM_STR) |
||
161 | |||
162 | /** |
||
163 | * Executes an SQL statement and return the number of affected rows. |
||
164 | * |
||
165 | * @param string $statement |
||
166 | * |
||
167 | * @return integer |
||
168 | */ |
||
169 | public function exec($statement) |
||
174 | |||
175 | /** |
||
176 | * Returns the ID of the last inserted row or sequence value. |
||
177 | * |
||
178 | * @param string|null $name |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function lastInsertId($name = null) |
||
186 | |||
187 | /** |
||
188 | * Initiates a transaction. |
||
189 | * |
||
190 | * @return boolean TRUE on success or FALSE on failure. |
||
191 | */ |
||
192 | public function beginTransaction() |
||
197 | |||
198 | /** |
||
199 | * Commits a transaction. |
||
200 | * |
||
201 | * @return boolean TRUE on success or FALSE on failure. |
||
202 | */ |
||
203 | public function commit() |
||
208 | |||
209 | /** |
||
210 | * Rolls back the current transaction, as initiated by beginTransaction(). |
||
211 | * |
||
212 | * @return boolean TRUE on success or FALSE on failure. |
||
213 | */ |
||
214 | public function rollBack() |
||
219 | |||
220 | /** |
||
221 | * Returns the error code associated with the last operation on the database handle. |
||
222 | * |
||
223 | * @return string|null The error code, or null if no operation has been run on the database handle. |
||
224 | */ |
||
225 | public function errorCode() |
||
229 | |||
230 | /** |
||
231 | * Returns extended error information associated with the last operation on the database handle. |
||
232 | * |
||
233 | * @return array |
||
234 | */ |
||
235 | public function errorInfo() |
||
239 | } |
||
240 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.