[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 /** 12 * @property string title The title of the database access layer. 13 * @property string short_title The short title of the database access layer. 14 * @property string type The type of db software being used. 15 * @property int query_count A count of the number of queries. 16 * @property array querylist A list of the performed queries. 17 * @property float query_time The time spent performing queries. 18 * @property string engine The engine used to run the SQL database. 19 * @property bool can_search Whether or not this engine can use the search functionality. 20 */ 21 interface DB_Base 22 { 23 /** 24 * Connect to the database server. 25 * 26 * @param array $config Array of DBMS connection details. 27 * @return resource|PDOStatement|mysqli_result The DB connection resource. Returns false on fail or -1 on a db connect failure. 28 */ 29 function connect($config); 30 31 /** 32 * Query the database. 33 * 34 * @param string $string The query SQL. 35 * @param integer|bool $hide_errors 1 if hide errors, 0 if not. 36 * @param integer 1 $write_query if executes on master database, 0 if not. 37 * @return resource|PDOStatement|mysqli_result The query data. 38 */ 39 function query($string, $hide_errors=0, $write_query=0); 40 41 /** 42 * Execute a write query on the master database 43 * 44 * @param string $query The query SQL. 45 * @param boolean|int $hide_errors 1 if hide errors, 0 if not. 46 * @return resource|PDOStatement|mysqli_result The query data. 47 */ 48 function write_query($query, $hide_errors=0); 49 50 /** 51 * Explain a query on the database. 52 * 53 * @param string $string The query SQL. 54 * @param string $qtime The time it took to perform the query. 55 */ 56 function explain_query($string, $qtime); 57 58 /** 59 * Return a result array for a query. 60 * 61 * @param resource|PDOStatement|mysqli_result $query The query ID. 62 * @param int $resulttype The type of array to return. Specified with the different constants for the type using 63 * 64 * @return array The array of results. 65 */ 66 function fetch_array($query, $resulttype=1); 67 68 /** 69 * Return a specific field from a query. 70 * 71 * @param resource|PDOStatement|mysqli_result $query The query ID. 72 * @param string $field The name of the field to return. 73 * @param int|boolean $row The number of the row to fetch it from. 74 */ 75 function fetch_field($query, $field, $row=false); 76 77 /** 78 * Moves internal row pointer to the next row 79 * 80 * @param resource|PDOStatement|mysqli_result $query The query ID. 81 * @param int $row The pointer to move the row to. 82 */ 83 function data_seek($query, $row); 84 85 /** 86 * Return the number of rows resulting from a query. 87 * 88 * @param resource|PDOStatement|mysqli_result $query The query ID. 89 * @return int The number of rows in the result. 90 */ 91 function num_rows($query); 92 93 /** 94 * Return the last id number of inserted data. 95 * 96 * @return int The id number. 97 */ 98 function insert_id(); 99 100 /** 101 * Close the connection with the DBMS. 102 * 103 */ 104 function close(); 105 106 /** 107 * Return an error number. 108 * 109 * @return int The error number of the current error. 110 */ 111 function error_number(); 112 113 /** 114 * Return an error string. 115 * 116 * @return string The explanation for the current error. 117 */ 118 function error_string(); 119 120 /** 121 * Output a database error. 122 * 123 * @param string $string The string to present as an error. 124 */ 125 function error($string=""); 126 127 /** 128 * Returns the number of affected rows in a query. 129 * 130 * @return int The number of affected rows. 131 */ 132 function affected_rows(); 133 134 /** 135 * Return the number of fields. 136 * 137 * @param resource|PDOStatement|mysqli_result $query The query ID. 138 * @return int The number of fields. 139 */ 140 function num_fields($query); 141 142 /** 143 * Lists all functions in the database. 144 * 145 * @param string $database The database name. 146 * @param string $prefix Prefix of the table (optional) 147 * @return array The table list. 148 */ 149 function list_tables($database, $prefix=''); 150 151 /** 152 * Check if a table exists in a database. 153 * 154 * @param string $table The table name. 155 * @return boolean True when exists, false if not. 156 */ 157 function table_exists($table); 158 159 /** 160 * Check if a field exists in a database. 161 * 162 * @param string $field The field name. 163 * @param string $table The table name. 164 * @return boolean True when exists, false if not. 165 */ 166 function field_exists($field, $table); 167 168 /** 169 * Add a shutdown query. 170 * 171 * @param resource|PDOStatement|mysqli_result $query The query data. 172 * @param string $name An optional name for the query. 173 */ 174 function shutdown_query($query, $name=''); 175 176 /** 177 * Performs a simple select query. 178 * 179 * @param string $table The table name to be queried. 180 * @param string $fields Comma delimited list of fields to be selected. 181 * @param string $conditions SQL formatted list of conditions to be matched. 182 * @param array $options List of options: group by, order by, order direction, limit, limit start. 183 * @return resource|PDOStatement|mysqli_result The query data. 184 */ 185 function simple_select($table, $fields="*", $conditions="", $options=array()); 186 187 /** 188 * Build an insert query from an array. 189 * 190 * @param string $table The table name to perform the query on. 191 * @param array $array An array of fields and their values. 192 * @return int The insert ID if available 193 */ 194 function insert_query($table, $array); 195 196 /** 197 * Build one query for multiple inserts from a multidimensional array. 198 * 199 * @param string $table The table name to perform the query on. 200 * @param array $array An array of inserts. 201 * @return void 202 */ 203 function insert_query_multiple($table, $array); 204 205 /** 206 * Build an update query from an array. 207 * 208 * @param string $table The table name to perform the query on. 209 * @param array $array An array of fields and their values. 210 * @param string $where An optional where clause for the query. 211 * @param string $limit An optional limit clause for the query. 212 * @param boolean $no_quote An option to quote incoming values of the array. 213 * @return resource|PDOStatement|mysqli_result The query data. 214 */ 215 function update_query($table, $array, $where="", $limit="", $no_quote=false); 216 217 /** 218 * Build a delete query. 219 * 220 * @param string $table The table name to perform the query on. 221 * @param string $where An optional where clause for the query. 222 * @param string $limit An optional limit clause for the query. 223 * @return resource|PDOStatement|mysqli_result The query data. 224 */ 225 function delete_query($table, $where="", $limit=""); 226 227 /** 228 * Escape a string according to the MySQL escape format. 229 * 230 * @param string $string The string to be escaped. 231 * @return string The escaped string. 232 */ 233 function escape_string($string); 234 235 /** 236 * Frees the resources of a query. 237 * 238 * @param resource|PDOStatement|mysqli_result $query The query to destroy. 239 * @return boolean Returns true on success, false on faliure 240 */ 241 function free_result($query); 242 243 /** 244 * Escape a string used within a like command. 245 * 246 * @param string $string The string to be escaped. 247 * @return string The escaped string. 248 */ 249 function escape_string_like($string); 250 251 /** 252 * Gets the current version of MySQL. 253 * 254 * @return string Version of MySQL. 255 */ 256 function get_version(); 257 258 /** 259 * Optimizes a specific table. 260 * 261 * @param string $table The name of the table to be optimized. 262 */ 263 function optimize_table($table); 264 265 /** 266 * Analyzes a specific table. 267 * 268 * @param string $table The name of the table to be analyzed. 269 */ 270 function analyze_table($table); 271 272 /** 273 * Show the "create table" command for a specific table. 274 * 275 * @param string $table The name of the table. 276 * @return string The SQL command to create the specified table. 277 */ 278 function show_create_table($table); 279 280 /** 281 * Show the "show fields from" command for a specific table. 282 * 283 * @param string $table The name of the table. 284 * @return array Field info for that table 285 */ 286 function show_fields_from($table); 287 288 /** 289 * Returns whether or not the table contains a fulltext index. 290 * 291 * @param string $table The name of the table. 292 * @param string $index Optionally specify the name of the index. 293 * @return boolean True or false if the table has a fulltext index or not. 294 */ 295 function is_fulltext($table, $index=""); 296 297 /** 298 * Returns whether or not this database engine supports fulltext indexing. 299 * 300 * @param string $table The table to be checked. 301 * @return boolean True or false if supported or not. 302 */ 303 function supports_fulltext($table); 304 305 /** 306 * Checks to see if an index exists on a specified table 307 * 308 * @param string $table The name of the table. 309 * @param string $index The name of the index. 310 */ 311 function index_exists($table, $index); 312 313 /** 314 * Returns whether or not this database engine supports boolean fulltext matching. 315 * 316 * @param string $table The table to be checked. 317 * @return boolean True or false if supported or not. 318 */ 319 function supports_fulltext_boolean($table); 320 321 /** 322 * Creates a fulltext index on the specified column in the specified table with optional index name. 323 * 324 * @param string $table The name of the table. 325 * @param string $column Name of the column to be indexed. 326 * @param string $name The index name, optional. 327 */ 328 function create_fulltext_index($table, $column, $name=""); 329 330 /** 331 * Drop an index with the specified name from the specified table 332 * 333 * @param string $table The name of the table. 334 * @param string $name The name of the index. 335 */ 336 function drop_index($table, $name); 337 338 /** 339 * Drop an table with the specified table 340 * 341 * @param string $table The name of the table. 342 * @param boolean $hard Hard drop - no checking 343 * @param boolean $table_prefix Use table prefix? 344 */ 345 function drop_table($table, $hard=false, $table_prefix=true); 346 347 /** 348 * Renames a table 349 * 350 * @param string $old_table The old table name 351 * @param string $new_table the new table name 352 * @param boolean $table_prefix Use table prefix? 353 */ 354 function rename_table($old_table, $new_table, $table_prefix=true); 355 356 /** 357 * Replace contents of table with values 358 * 359 * @param string $table The table 360 * @param array $replacements The replacements 361 * @param string|array $default_field The default field(s) 362 * @param boolean $insert_id Whether or not to return an insert id. True by default 363 */ 364 function replace_query($table, $replacements=array(), $default_field="", $insert_id=true); 365 366 /** 367 * Drops a column 368 * 369 * @param string $table The table 370 * @param string $column The column name 371 */ 372 function drop_column($table, $column); 373 374 /** 375 * Adds a column 376 * 377 * @param string $table The table 378 * @param string $column The column name 379 * @param string $definition The new column definition 380 */ 381 function add_column($table, $column, $definition); 382 383 /** 384 * Modifies a column 385 * 386 * @param string $table The table 387 * @param string $column The column name 388 * @param string $new_definition the new column definition 389 * @param boolean|string $new_not_null Whether to "drop" or "set" the NOT NULL attribute (no change if false) 390 * @param boolean|string $new_default_value The new default value, or false to drop the attribute 391 * @return bool Returns true if all queries are executed successfully or false if one of them failed 392 */ 393 function modify_column($table, $column, $new_definition, $new_not_null=false, $new_default_value=false); 394 395 /** 396 * Renames a column 397 * 398 * @param string $table The table 399 * @param string $old_column The old column name 400 * @param string $new_column the new column name 401 * @param string $new_definition the new column definition 402 * @param boolean|string $new_not_null Whether to "drop" or "set" the NOT NULL attribute (no change if false) 403 * @param boolean|string $new_default_value The new default value, or false to drop the attribute 404 * @return bool Returns true if all queries are executed successfully 405 */ 406 function rename_column($table, $old_column, $new_column, $new_definition, $new_not_null=false, $new_default_value=false); 407 408 /** 409 * Sets the table prefix used by the simple select, insert, update and delete functions 410 * 411 * @param string $prefix The new table prefix 412 */ 413 function set_table_prefix($prefix); 414 415 /** 416 * Fetched the total size of all mysql tables or a specific table 417 * 418 * @param string $table The table (optional) 419 * @return integer the total size of all mysql tables or a specific table 420 */ 421 function fetch_size($table=''); 422 423 /** 424 * Fetch a list of database character sets this DBMS supports 425 * 426 * @return array|bool Array of supported character sets with array key being the name, array value being display name. False if unsupported 427 */ 428 function fetch_db_charsets(); 429 430 /** 431 * Fetch a database collation for a particular database character set 432 * 433 * @param string $charset The database character set 434 * @return string|bool The matching database collation, false if unsupported 435 */ 436 function fetch_charset_collation($charset); 437 438 /** 439 * Fetch a character set/collation string for use with CREATE TABLE statements. Uses current DB encoding 440 * 441 * @return string The built string, empty if unsupported 442 */ 443 function build_create_table_collation(); 444 445 /** 446 * Time how long it takes for a particular piece of code to run. Place calls above & below the block of code. 447 * 448 * @deprecated 449 */ 450 function get_execution_time(); 451 452 /** 453 * Binary database fields require special attention. 454 * 455 * @param string $string Binary value 456 * @return string Encoded binary value 457 */ 458 function escape_binary($string); 459 460 /** 461 * Unescape binary data. 462 * 463 * @param string $string Binary value 464 * @return string Encoded binary value 465 */ 466 function unescape_binary($string); 467 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |