1 | <?php |
||
31 | trait ConnectTrait |
||
32 | { |
||
33 | /** |
||
34 | * the connection link |
||
35 | * |
||
36 | * @var mixed |
||
37 | * @access protected |
||
38 | */ |
||
39 | protected $link; |
||
40 | |||
41 | /** |
||
42 | * connect parameters |
||
43 | * |
||
44 | * @var array |
||
45 | * @access protected |
||
46 | */ |
||
47 | protected $connect_parameters = []; |
||
48 | |||
49 | /** |
||
50 | * connection attributes |
||
51 | * |
||
52 | * @var array |
||
53 | * @access protected |
||
54 | */ |
||
55 | protected $attributes = []; |
||
56 | |||
57 | /** |
||
58 | * {@inheritDoc} |
||
59 | */ |
||
60 | public function connect() |
||
74 | |||
75 | /** |
||
76 | * {@inheritDoc} |
||
77 | */ |
||
78 | public function disconnect() |
||
86 | |||
87 | /** |
||
88 | * {@inheritDoc} |
||
89 | */ |
||
90 | public function isConnected()/*# : bool */ |
||
94 | |||
95 | /** |
||
96 | * {@inheritDoc} |
||
97 | */ |
||
98 | public function ping()/*# : bool */ |
||
107 | |||
108 | /** |
||
109 | * {@inheritDoc} |
||
110 | */ |
||
111 | public function getLink() |
||
116 | |||
117 | /** |
||
118 | * {@inheritDoc} |
||
119 | */ |
||
120 | public function setAttribute(/*# string */ $attribute, $value) |
||
128 | |||
129 | /** |
||
130 | * {@inheritDoc} |
||
131 | */ |
||
132 | public function getAttribute(/*# string */ $attribute) |
||
145 | |||
146 | /** |
||
147 | * Set default attributes |
||
148 | * |
||
149 | * @access protected |
||
150 | */ |
||
151 | protected function setDefaultAttributes() |
||
159 | |||
160 | /** |
||
161 | * Driver specific connect |
||
162 | * |
||
163 | * @param array $parameters |
||
164 | * @return mixed the link |
||
165 | * @throws \Exception |
||
166 | * @access protected |
||
167 | */ |
||
168 | abstract protected function realConnect(array $parameters); |
||
169 | |||
170 | /** |
||
171 | * Driver specific disconnect |
||
172 | * |
||
173 | * @access protected |
||
174 | */ |
||
175 | abstract protected function realDisconnect(); |
||
176 | |||
177 | /** |
||
178 | * Driver related ping |
||
179 | * |
||
180 | * @return bool |
||
181 | * @access protected |
||
182 | */ |
||
183 | abstract protected function realPing()/*# : bool */; |
||
184 | |||
185 | /** |
||
186 | * Set connection specific attribute |
||
187 | * |
||
188 | * @param string attribute |
||
189 | * @param mixed $value |
||
190 | * @throws LogicException if attribute unknown |
||
191 | * @access protected |
||
192 | */ |
||
193 | abstract protected function realSetAttribute( |
||
197 | |||
198 | /** |
||
199 | * Get connection specific attribute |
||
200 | * |
||
201 | * @param string attribute |
||
202 | * @return mixed|null |
||
203 | * @throws LogicException if attribute unknown |
||
204 | * @access protected |
||
205 | */ |
||
206 | abstract protected function realGetAttribute(/*# string */ $attribute); |
||
207 | |||
208 | // from ErrorAwareInterface |
||
209 | abstract public function setError( |
||
213 | } |
||
214 |