1 | <?php |
||
15 | class MySqlConnector extends Connector |
||
16 | { |
||
17 | /** |
||
18 | * Establish a database connection. |
||
19 | * |
||
20 | * @param array $config |
||
21 | * @return \PDO |
||
22 | */ |
||
23 | public function connect(array $config) |
||
49 | |||
50 | /** |
||
51 | * Set the connection character set and collation. |
||
52 | * |
||
53 | * @param \PDO $connection |
||
54 | * @param array $config |
||
55 | * @return void |
||
56 | */ |
||
57 | protected function configureEncoding($connection, array $config) |
||
67 | |||
68 | /** |
||
69 | * Get the collation for the configuration. |
||
70 | * |
||
71 | * @param array $config |
||
72 | * @return string |
||
73 | */ |
||
74 | protected function getCollation(array $config) |
||
78 | |||
79 | /** |
||
80 | * Set the timezone on the connection. |
||
81 | * |
||
82 | * @param \PDO $connection |
||
83 | * @param array $config |
||
84 | * @return void |
||
85 | */ |
||
86 | protected function configureTimezone($connection, array $config) |
||
92 | |||
93 | /** |
||
94 | * Create a DSN string from a configuration. |
||
95 | * |
||
96 | * Chooses socket or host/port based on the 'unix_socket' config value. |
||
97 | * |
||
98 | * @param array $config |
||
99 | * @return string |
||
100 | */ |
||
101 | protected function getDsn(array $config) |
||
107 | |||
108 | /** |
||
109 | * Determine if the given configuration array has a UNIX socket value. |
||
110 | * |
||
111 | * @param array $config |
||
112 | * @return bool |
||
113 | */ |
||
114 | protected function hasSocket(array $config) |
||
118 | |||
119 | /** |
||
120 | * Get the DSN string for a socket configuration. |
||
121 | * |
||
122 | * @param array $config |
||
123 | * @return string |
||
124 | */ |
||
125 | protected function getSocketDsn(array $config) |
||
129 | |||
130 | /** |
||
131 | * Get the DSN string for a host / port configuration. |
||
132 | * |
||
133 | * @param array $config |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function getHostDsn(array $config) |
||
144 | |||
145 | /** |
||
146 | * Set the modes for the connection. |
||
147 | * |
||
148 | * @param \PDO $connection |
||
149 | * @param array $config |
||
150 | * @return void |
||
151 | */ |
||
152 | protected function setModes(PDO $connection, array $config) |
||
164 | |||
165 | /** |
||
166 | * Set the custom modes on the connection. |
||
167 | * |
||
168 | * @param \PDO $connection |
||
169 | * @param array $config |
||
170 | * @return void |
||
171 | */ |
||
172 | protected function setCustomModes(PDO $connection, array $config) |
||
178 | |||
179 | /** |
||
180 | * Get the query to enable strict mode. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | protected function strictMode() |
||
188 | } |