1 | <?php |
||
7 | abstract class ConnectionBase implements ConnectionInterface |
||
8 | { |
||
9 | /** |
||
10 | * The connection parameters for the database server. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $connection_params = array('host' => '127.0.0.1', 'port' => 9306, 'socket' => null); |
||
15 | |||
16 | /** |
||
17 | * Internal connection object. |
||
18 | */ |
||
19 | protected $connection; |
||
20 | |||
21 | /** |
||
22 | * Disables any warning outputs returned on the connection with @ prefix. |
||
23 | * |
||
24 | * @var boolean |
||
25 | */ |
||
26 | protected $silence_connection_warning = false; |
||
27 | |||
28 | /** |
||
29 | * Sets one or more connection parameters. |
||
30 | * |
||
31 | * @param array $params Associative array of parameters and values. |
||
32 | */ |
||
33 | public function setParams(Array $params) |
||
39 | |||
40 | /** |
||
41 | * Set a single connection parameter. Valid parameters include: |
||
42 | * |
||
43 | * * string host - The hostname, IP address, or unix socket |
||
44 | * * int port - The port to the host |
||
45 | * * array options - MySQLi options/values, as an associative array. Example: array(MYSQLI_OPT_CONNECT_TIMEOUT => 2) |
||
46 | * |
||
47 | * @param string $param Name of the parameter to modify. |
||
48 | * @param mixed $value Value to which the parameter will be set. |
||
49 | */ |
||
50 | public function setParam($param, $value) |
||
68 | |||
69 | /** |
||
70 | * Returns the connection parameters (host, port, connection timeout) for the current instance. |
||
71 | * |
||
72 | * @return array $params The current connection parameters |
||
73 | */ |
||
74 | public function getParams() |
||
78 | |||
79 | /** |
||
80 | * Returns the current connection established. |
||
81 | * |
||
82 | * @return object Internal connection object |
||
83 | * @throws ConnectionException If no connection has been established or open |
||
84 | */ |
||
85 | public function getConnection() |
||
93 | |||
94 | /** |
||
95 | * Adds quotes around values when necessary. |
||
96 | * Based on FuelPHP's quoting function. |
||
97 | * |
||
98 | * @param Expression|string|null|bool|array|int|float $value The input string, eventually wrapped in an expression |
||
99 | * to leave it untouched |
||
100 | * |
||
101 | * @return Expression|string|int The untouched Expression or the quoted string |
||
102 | */ |
||
103 | public function quote($value) |
||
126 | |||
127 | /** |
||
128 | * Calls $this->quote() on every element of the array passed. |
||
129 | * |
||
130 | * @param array $array The array of strings to quote |
||
131 | * |
||
132 | * @return array The array of quotes strings |
||
133 | */ |
||
134 | public function quoteArr(Array $array = array()) |
||
144 | |||
145 | /** |
||
146 | * Closes and unset the connection to the Sphinx server. |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function close() |
||
155 | |||
156 | /** |
||
157 | * Establishes a connection if needed |
||
158 | * @throws ConnectionException |
||
159 | */ |
||
160 | protected function ensureConnection() |
||
168 | |||
169 | /** |
||
170 | * Establishes a connection to the Sphinx server. |
||
171 | * |
||
172 | * @param bool $suppress_error If the warnings on the connection should be suppressed |
||
173 | * |
||
174 | * @return bool True if connected |
||
175 | * @throws ConnectionException If a connection error was encountered |
||
176 | */ |
||
177 | abstract public function connect($suppress_error = false); |
||
178 | |||
179 | /** |
||
180 | * Forces the connection to suppress all errors returned. This should only be used |
||
181 | * when the production server is running with high error reporting settings. |
||
182 | * |
||
183 | * @param boolean $enable True if it should be enabled, false if it should be disabled |
||
184 | * @deprecated |
||
185 | * not good |
||
186 | */ |
||
187 | public function silenceConnectionWarning($enable = true) |
||
191 | } |
||
192 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.