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 */ $connect = false)/*# : bool */ |
||
110 | |||
111 | /** |
||
112 | * {@inheritDoc} |
||
113 | */ |
||
114 | public function getLink() |
||
119 | |||
120 | /** |
||
121 | * {@inheritDoc} |
||
122 | */ |
||
123 | public function setAttribute(/*# string */ $attribute, $value) |
||
131 | |||
132 | /** |
||
133 | * {@inheritDoc} |
||
134 | */ |
||
135 | public function getAttribute(/*# string */ $attribute) |
||
148 | |||
149 | /** |
||
150 | * Set default attributes |
||
151 | * |
||
152 | * @access protected |
||
153 | */ |
||
154 | protected function setDefaultAttributes() |
||
162 | |||
163 | /** |
||
164 | * Driver specific connect |
||
165 | * |
||
166 | * @param array $parameters |
||
167 | * @return mixed the link |
||
168 | * @throws \Exception |
||
169 | * @access protected |
||
170 | */ |
||
171 | abstract protected function realConnect(array $parameters); |
||
172 | |||
173 | /** |
||
174 | * Driver specific disconnect |
||
175 | * |
||
176 | * @access protected |
||
177 | */ |
||
178 | abstract protected function realDisconnect(); |
||
179 | |||
180 | /** |
||
181 | * Driver related ping |
||
182 | * |
||
183 | * @return bool |
||
184 | * @access protected |
||
185 | */ |
||
186 | abstract protected function realPing()/*# : bool */; |
||
187 | |||
188 | /** |
||
189 | * Set connection specific attribute |
||
190 | * |
||
191 | * @param string attribute |
||
192 | * @param mixed $value |
||
193 | * @throws LogicException if attribute unknown |
||
194 | * @access protected |
||
195 | */ |
||
196 | abstract protected function realSetAttribute( |
||
200 | |||
201 | /** |
||
202 | * Get connection specific attribute |
||
203 | * |
||
204 | * @param string attribute |
||
205 | * @return mixed|null |
||
206 | * @throws LogicException if attribute unknown |
||
207 | * @access protected |
||
208 | */ |
||
209 | abstract protected function realGetAttribute(/*# string */ $attribute); |
||
210 | |||
211 | // from ErrorAwareInterface |
||
212 | abstract public function setError( |
||
216 | } |
||
217 |