Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
driver_interface.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\db\driver;
015
016 interface driver_interface
017 {
018 /**
019 * Gets the name of the sql layer.
020 *
021 * @return string
022 */
023 public function get_sql_layer();
024
025 /**
026 * Gets the name of the database.
027 *
028 * @return string
029 */
030 public function get_db_name();
031
032 /**
033 * Wildcards for matching any (%) character within LIKE expressions
034 *
035 * @return string
036 */
037 public function get_any_char();
038
039 /**
040 * Wildcards for matching exactly one (_) character within LIKE expressions
041 *
042 * @return string
043 */
044 public function get_one_char();
045
046 /**
047 * Gets the time spent into the queries
048 *
049 * @return int
050 */
051 public function get_sql_time();
052
053 /**
054 * Gets the connect ID.
055 *
056 * @return mixed
057 */
058 public function get_db_connect_id();
059
060 /**
061 * Indicates if an error was triggered.
062 *
063 * @return bool
064 */
065 public function get_sql_error_triggered();
066
067 /**
068 * Gets the last faulty query
069 *
070 * @return string
071 */
072 public function get_sql_error_sql();
073
074 /**
075 * Indicates if we are in a transaction.
076 *
077 * @return bool
078 */
079 public function get_transaction();
080
081 /**
082 * Gets the returned error.
083 *
084 * @return array
085 */
086 public function get_sql_error_returned();
087
088 /**
089 * Indicates if multiple insertion can be used
090 *
091 * @return bool
092 */
093 public function get_multi_insert();
094
095 /**
096 * Set if multiple insertion can be used
097 *
098 * @param bool $multi_insert
099 */
100 public function set_multi_insert($multi_insert);
101
102 /**
103 * Gets the exact number of rows in a specified table.
104 *
105 * @param string $table_name Table name
106 * @return string Exact number of rows in $table_name.
107 */
108 public function get_row_count($table_name);
109
110 /**
111 * Gets the estimated number of rows in a specified table.
112 *
113 * @param string $table_name Table name
114 * @return string Number of rows in $table_name.
115 * Prefixed with ~ if estimated (otherwise exact).
116 */
117 public function get_estimated_row_count($table_name);
118
119 /**
120 * Run LOWER() on DB column of type text (i.e. neither varchar nor char).
121 *
122 * @param string $column_name The column name to use
123 * @return string A SQL statement like "LOWER($column_name)"
124 */
125 public function sql_lower_text($column_name);
126
127 /**
128 * Display sql error page
129 *
130 * @param string $sql The SQL query causing the error
131 * @return mixed Returns the full error message, if $this->return_on_error
132 * is set, null otherwise
133 */
134 public function sql_error($sql = '');
135
136 /**
137 * Returns whether results of a query need to be buffered to run a
138 * transaction while iterating over them.
139 *
140 * @return bool Whether buffering is required.
141 */
142 public function sql_buffer_nested_transactions();
143
144 /**
145 * Run binary OR operator on DB column.
146 *
147 * @param string $column_name The column name to use
148 * @param int $bit The value to use for the OR operator,
149 * will be converted to (1 << $bit). Is used by options,
150 * using the number schema... 0, 1, 2...29
151 * @param string $compare Any custom SQL code after the check (e.g. "= 0")
152 * @return string A SQL statement like "$column | (1 << $bit) {$compare}"
153 */
154 public function sql_bit_or($column_name, $bit, $compare = '');
155
156 /**
157 * Version information about used database
158 *
159 * @param bool $raw Only return the fetched sql_server_version
160 * @param bool $use_cache Is it safe to retrieve the value from the cache
161 * @return string sql server version
162 */
163 public function sql_server_info($raw = false, $use_cache = true);
164
165 /**
166 * Return on error or display error message
167 *
168 * @param bool $fail Should we return on errors, or stop
169 * @return null
170 */
171 public function sql_return_on_error($fail = false);
172
173 /**
174 * Build sql statement from an array
175 *
176 * @param string $query Should be on of the following strings:
177 * INSERT, INSERT_SELECT, UPDATE, SELECT, DELETE
178 * @param array $assoc_ary Array with "column => value" pairs
179 * @return string A SQL statement like "c1 = 'a' AND c2 = 'b'"
180 */
181 public function sql_build_array($query, $assoc_ary = array());
182
183 /**
184 * Fetch all rows
185 *
186 * @param mixed $query_id Already executed query to get the rows from,
187 * if false, the last query will be used.
188 * @return mixed Nested array if the query had rows, false otherwise
189 */
190 public function sql_fetchrowset($query_id = false);
191
192 /**
193 * SQL Transaction
194 *
195 * @param string $status Should be one of the following strings:
196 * begin, commit, rollback
197 * @return mixed Buffered, seekable result handle, false on error
198 */
199 public function sql_transaction($status = 'begin');
200
201 /**
202 * Build a concatenated expression
203 *
204 * @param string $expr1 Base SQL expression where we append the second one
205 * @param string $expr2 SQL expression that is appended to the first expression
206 * @return string Concatenated string
207 */
208 public function sql_concatenate($expr1, $expr2);
209
210 /**
211 * Build a case expression
212 *
213 * Note: The two statements action_true and action_false must have the same
214 * data type (int, vchar, ...) in the database!
215 *
216 * @param string $condition The condition which must be true,
217 * to use action_true rather then action_else
218 * @param string $action_true SQL expression that is used, if the condition is true
219 * @param mixed $action_false SQL expression that is used, if the condition is false
220 * @return string CASE expression including the condition and statements
221 */
222 public function sql_case($condition, $action_true, $action_false = false);
223
224 /**
225 * Build sql statement from array for select and select distinct statements
226 *
227 * Possible query values: SELECT, SELECT_DISTINCT
228 *
229 * @param string $query Should be one of: SELECT, SELECT_DISTINCT
230 * @param array $array Array with the query data:
231 * SELECT A comma imploded list of columns to select
232 * FROM Array with "table => alias" pairs,
233 * (alias can also be an array)
234 * Optional: LEFT_JOIN Array of join entries:
235 * FROM Table that should be joined
236 * ON Condition for the join
237 * Optional: WHERE Where SQL statement
238 * Optional: GROUP_BY Group by SQL statement
239 * Optional: ORDER_BY Order by SQL statement
240 * @return string A SQL statement ready for execution
241 */
242 public function sql_build_query($query, $array);
243
244 /**
245 * Fetch field
246 * if rownum is false, the current row is used, else it is pointing to the row (zero-based)
247 *
248 * @param string $field Name of the column
249 * @param mixed $rownum Row number, if false the current row will be used
250 * and the row curser will point to the next row
251 * Note: $rownum is 0 based
252 * @param mixed $query_id Already executed query to get the rows from,
253 * if false, the last query will be used.
254 * @return mixed String value of the field in the selected row,
255 * false, if the row does not exist
256 */
257 public function sql_fetchfield($field, $rownum = false, $query_id = false);
258
259 /**
260 * Fetch current row
261 *
262 * @param mixed $query_id Already executed query to get the rows from,
263 * if false, the last query will be used.
264 * @return mixed Array with the current row,
265 * false, if the row does not exist
266 */
267 public function sql_fetchrow($query_id = false);
268
269 /**
270 * Returns SQL string to cast a string expression to an int.
271 *
272 * @param string $expression An expression evaluating to string
273 * @return string Expression returning an int
274 */
275 public function cast_expr_to_bigint($expression);
276
277 /**
278 * Get last inserted id after insert statement
279 *
280 * @return string Autoincrement value of the last inserted row
281 */
282 public function sql_nextid();
283
284 /**
285 * Add to query count
286 *
287 * @param bool $cached Is this query cached?
288 * @return null
289 */
290 public function sql_add_num_queries($cached = false);
291
292 /**
293 * Build LIMIT query
294 *
295 * @param string $query The SQL query to execute
296 * @param int $total The number of rows to select
297 * @param int $offset
298 * @param int $cache_ttl Either 0 to avoid caching or
299 * the time in seconds which the result shall be kept in cache
300 * @return mixed Buffered, seekable result handle, false on error
301 */
302 public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0);
303
304 /**
305 * Base query method
306 *
307 * @param string $query The SQL query to execute
308 * @param int $cache_ttl Either 0 to avoid caching or
309 * the time in seconds which the result shall be kept in cache
310 * @return mixed Buffered, seekable result handle, false on error
311 */
312 public function sql_query($query = '', $cache_ttl = 0);
313
314 /**
315 * Returns SQL string to cast an integer expression to a string.
316 *
317 * @param string $expression An expression evaluating to int
318 * @return string Expression returning a string
319 */
320 public function cast_expr_to_string($expression);
321
322 /**
323 * Connect to server
324 *
325 * @param string $sqlserver Address of the database server
326 * @param string $sqluser User name of the SQL user
327 * @param string $sqlpassword Password of the SQL user
328 * @param string $database Name of the database
329 * @param mixed $port Port of the database server
330 * @param bool $persistency
331 * @param bool $new_link Should a new connection be established
332 * @return mixed Connection ID on success, string error message otherwise
333 */
334 public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false);
335
336 /**
337 * Run binary AND operator on DB column.
338 * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}"
339 *
340 * @param string $column_name The column name to use
341 * @param int $bit The value to use for the AND operator,
342 * will be converted to (1 << $bit). Is used by
343 * options, using the number schema: 0, 1, 2...29
344 * @param string $compare Any custom SQL code after the check (for example "= 0")
345 * @return string A SQL statement like: "{$column} & (1 << {$bit}) {$compare}"
346 */
347 public function sql_bit_and($column_name, $bit, $compare = '');
348
349 /**
350 * Free sql result
351 *
352 * @param mixed $query_id Already executed query result,
353 * if false, the last query will be used.
354 * @return null
355 */
356 public function sql_freeresult($query_id = false);
357
358 /**
359 * Return number of sql queries and cached sql queries used
360 *
361 * @param bool $cached Should we return the number of cached or normal queries?
362 * @return int Number of queries that have been executed
363 */
364 public function sql_num_queries($cached = false);
365
366 /**
367 * Run more than one insert statement.
368 *
369 * @param string $table Table name to run the statements on
370 * @param array $sql_ary Multi-dimensional array holding the statement data
371 * @return bool false if no statements were executed.
372 */
373 public function sql_multi_insert($table, $sql_ary);
374
375 /**
376 * Return number of affected rows
377 *
378 * @return mixed Number of the affected rows by the last query
379 * false if no query has been run before
380 */
381 public function sql_affectedrows();
382
383 /**
384 * DBAL garbage collection, close SQL connection
385 *
386 * @return mixed False if no connection was opened before,
387 * Server response otherwise
388 */
389 public function sql_close();
390
391 /**
392 * Seek to given row number
393 *
394 * @param mixed $rownum Row number the curser should point to
395 * Note: $rownum is 0 based
396 * @param mixed $query_id ID of the query to set the row cursor on
397 * if false, the last query will be used.
398 * $query_id will then be set correctly
399 * @return bool False if something went wrong
400 */
401 public function sql_rowseek($rownum, &$query_id);
402
403 /**
404 * Escape string used in sql query
405 *
406 * @param string $msg String to be escaped
407 * @return string Escaped version of $msg
408 */
409 public function sql_escape($msg);
410
411 /**
412 * Correctly adjust LIKE expression for special characters
413 * Some DBMS are handling them in a different way
414 *
415 * @param string $expression The expression to use. Every wildcard is
416 * escaped, except $this->any_char and $this->one_char
417 * @return string A SQL statement like: "LIKE 'bertie_%'"
418 */
419 public function sql_like_expression($expression);
420
421 /**
422 * Correctly adjust NOT LIKE expression for special characters
423 * Some DBMS are handling them in a different way
424 *
425 * @param string $expression The expression to use. Every wildcard is
426 * escaped, except $this->any_char and $this->one_char
427 * @return string A SQL statement like: "NOT LIKE 'bertie_%'"
428 */
429 public function sql_not_like_expression($expression);
430
431 /**
432 * Explain queries
433 *
434 * @param string $mode Available modes: display, start, stop,
435 * add_select_row, fromcache, record_fromcache
436 * @param string $query The Query that should be explained
437 * @return mixed Either a full HTML page, boolean or null
438 */
439 public function sql_report($mode, $query = '');
440
441 /**
442 * Build IN or NOT IN sql comparison string, uses <> or = on single element
443 * arrays to improve comparison speed
444 *
445 * @param string $field Name of the sql column that shall be compared
446 * @param array $array Array of values that are (not) allowed
447 * @param bool $negate true for NOT IN (), false for IN ()
448 * @param bool $allow_empty_set If true, allow $array to be empty,
449 * this function will return 1=1 or 1=0 then.
450 * @return string A SQL statement like: "IN (1, 2, 3, 4)" or "= 1"
451 */
452 public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false);
453 }
454