Ticket #49477: 49477_1.diff
| File 49477_1.diff, 52.5 KB (added by , 6 years ago) |
|---|
-
src/wp-includes/wp-db.php
1 1 <?php 2 2 /** 3 * WordPress DB Class3 * WordPress database access abstraction class 4 4 * 5 5 * Original code from {@link http://php.justinvincent.com Justin Vincent (justin@visunet.ie)} 6 6 * … … 37 37 define( 'ARRAY_N', 'ARRAY_N' ); 38 38 39 39 /** 40 * WordPress Database Access Abstraction Object40 * WordPress database access abstraction class 41 41 * 42 * It is possible to replace this class with your own 43 * by setting the $wpdb global variable in wp-content/db.php 44 * file to your class. The wpdb class will still be included, 45 * so you can extend it or simply use your own. 42 * This class is used to interact with a database without needing to use raw SQL statements. By default, WordPress 43 * uses this class to instantiate the global $wpdb object, providing access to the WordPress database. 46 44 * 47 * @link https:// codex.wordpress.org/Function_Reference/wpdb_Class45 * @link https://developer.wordpress.org/reference/classes/wpdb/ 48 46 * 49 47 * @since 0.71 50 48 */ … … 53 51 /** 54 52 * Whether to show SQL/DB errors. 55 53 * 56 * Default behavior is to show errors if both WP_DEBUG and WP_DEBUG_DISPLAY 57 * evaluated to true. 54 * Default is to show errors if both WP_DEBUG and WP_DEBUG_DISPLAY evaluated to true. 58 55 * 59 56 * @since 0.71 60 57 * @var bool … … 62 59 var $show_errors = false; 63 60 64 61 /** 65 * Whether to suppress errors during the DB bootstrapping. 62 * Whether to suppress errors during the DB bootstrapping. Default is false. 66 63 * 67 64 * @since 2.5.0 68 65 * @var bool … … 70 67 var $suppress_errors = false; 71 68 72 69 /** 73 * The last error duringquery.70 * The last error encountered during the last query. 74 71 * 75 72 * @since 2.5.0 76 73 * @var string … … 78 75 public $last_error = ''; 79 76 80 77 /** 81 * Amount of queries made78 * The number of queries made. 82 79 * 83 80 * @since 1.2.0 84 81 * @var int … … 86 83 public $num_queries = 0; 87 84 88 85 /** 89 * Count of rows returned by previous query86 * Count of rows returned by the last query. 90 87 * 91 88 * @since 0.71 92 89 * @var int … … 94 91 public $num_rows = 0; 95 92 96 93 /** 97 * Count of affected rows by previous query94 * Count of rows affected by the last query. 98 95 * 99 96 * @since 0.71 100 97 * @var int … … 102 99 var $rows_affected = 0; 103 100 104 101 /** 105 * The ID generated for an AUTO_INCREMENT column by the previousquery (usually INSERT).102 * The ID generated for an AUTO_INCREMENT column by the last query (usually INSERT). 106 103 * 107 104 * @since 0.71 108 105 * @var int … … 110 107 public $insert_id = 0; 111 108 112 109 /** 113 * Last query made110 * The last query made. 114 111 * 115 112 * @since 0.71 116 113 * @var string … … 118 115 var $last_query; 119 116 120 117 /** 121 * Results of the last query made118 * Results of the last query. 122 119 * 123 120 * @since 0.71 124 121 * @var array|null … … 134 131 protected $result; 135 132 136 133 /** 137 * Cached column info, for sanity checking data before inserting 134 * Cached column info, for sanity checking data before inserting. 138 135 * 139 136 * @since 4.2.0 140 137 * @var array … … 142 139 protected $col_meta = array(); 143 140 144 141 /** 145 * Calculated character sets on tables 142 * Calculated character sets on tables. 146 143 * 147 144 * @since 4.2.0 148 145 * @var array … … 150 147 protected $table_charset = array(); 151 148 152 149 /** 153 * Whether text fields in the current query need to be sanity checked. 150 * Whether text fields in the current query need to be sanity checked. Default is false. 154 151 * 155 152 * @since 4.2.0 156 153 * @var bool … … 167 164 private $checking_collation = false; 168 165 169 166 /** 170 * Saved info on the table column 167 * Saved info on the table column. 171 168 * 172 169 * @since 0.71 173 170 * @var array … … 199 196 var $queries; 200 197 201 198 /** 202 * The number of times to retry reconnecting before dying. 199 * The number of times to retry reconnecting before dying. Default is 5. 203 200 * 204 201 * @since 3.9.0 205 202 * @see wpdb::check_connection() … … 210 207 /** 211 208 * WordPress table prefix 212 209 * 213 * You can set this to have multiple WordPress installations 214 * in a single database. The second reason is for possible 215 * security precautions. 210 * You can set this to have multiple WordPress installations in a single database. 211 * The second reason is for possible security precautions. 216 212 * 217 213 * @since 2.5.0 218 214 * @var string … … 252 248 public $siteid = 0; 253 249 254 250 /** 255 * List of WordPress per-blog tables 251 * List of WordPress per-blog tables. 256 252 * 257 253 * @since 2.5.0 258 254 * @see wpdb::tables() … … 272 268 ); 273 269 274 270 /** 275 * List of deprecated WordPress tables 271 * List of deprecated WordPress tables. 276 272 * 277 * categories, post2cat, and link2cat were deprecated in 2.3.0, db version 5539 273 * categories, post2cat, and link2cat were deprecated in 2.3.0, db version 5539. 278 274 * 279 275 * @since 2.9.0 280 276 * @see wpdb::tables() … … 283 279 var $old_tables = array( 'categories', 'post2cat', 'link2cat' ); 284 280 285 281 /** 286 * List of WordPress global tables 282 * List of WordPress global tables. 287 283 * 288 284 * @since 3.0.0 289 285 * @see wpdb::tables() … … 292 288 var $global_tables = array( 'users', 'usermeta' ); 293 289 294 290 /** 295 * List of Multisite global tables 291 * List of Multisite global tables. 296 292 * 297 293 * @since 3.0.0 298 294 * @see wpdb::tables() … … 309 305 ); 310 306 311 307 /** 312 * WordPress Comments table 308 * WordPress Comments table. 313 309 * 314 310 * @since 1.5.0 315 311 * @var string … … 317 313 public $comments; 318 314 319 315 /** 320 * WordPress Comment Metadata table 316 * WordPress Comment Metadata table. 321 317 * 322 318 * @since 2.9.0 323 319 * @var string … … 325 321 public $commentmeta; 326 322 327 323 /** 328 * WordPress Links table 324 * WordPress Links table. 329 325 * 330 326 * @since 1.5.0 331 327 * @var string … … 333 329 public $links; 334 330 335 331 /** 336 * WordPress Options table 332 * WordPress Options table. 337 333 * 338 334 * @since 1.5.0 339 335 * @var string … … 341 337 public $options; 342 338 343 339 /** 344 * WordPress Post Metadata table 340 * WordPress Post Metadata table. 345 341 * 346 342 * @since 1.5.0 347 343 * @var string … … 349 345 public $postmeta; 350 346 351 347 /** 352 * WordPress Posts table 348 * WordPress Posts table. 353 349 * 354 350 * @since 1.5.0 355 351 * @var string … … 357 353 public $posts; 358 354 359 355 /** 360 * WordPress Terms table 356 * WordPress Terms table. 361 357 * 362 358 * @since 2.3.0 363 359 * @var string … … 365 361 public $terms; 366 362 367 363 /** 368 * WordPress Term Relationships table 364 * WordPress Term Relationships table. 369 365 * 370 366 * @since 2.3.0 371 367 * @var string … … 373 369 public $term_relationships; 374 370 375 371 /** 376 * WordPress Term Taxonomy table 372 * WordPress Term Taxonomy table. 377 373 * 378 374 * @since 2.3.0 379 375 * @var string … … 393 389 // 394 390 395 391 /** 396 * WordPress User Metadata table 392 * WordPress User Metadata table. 397 393 * 398 394 * @since 2.3.0 399 395 * @var string … … 401 397 public $usermeta; 402 398 403 399 /** 404 * WordPress Users table 400 * WordPress Users table. 405 401 * 406 402 * @since 1.5.0 407 403 * @var string … … 409 405 public $users; 410 406 411 407 /** 412 * Multisite Blogs table 408 * Multisite Blogs table. 413 409 * 414 410 * @since 3.0.0 415 411 * @var string … … 417 413 public $blogs; 418 414 419 415 /** 420 * Multisite Blog Metadata table 416 * Multisite Blog Metadata table. 421 417 * 422 418 * @since 5.1.0 423 419 * @var string … … 425 421 public $blogmeta; 426 422 427 423 /** 428 * Multisite Registration Log table 424 * Multisite Registration Log table. 429 425 * 430 426 * @since 3.0.0 431 427 * @var string … … 433 429 public $registration_log; 434 430 435 431 /** 436 * Multisite Signups table 432 * Multisite Signups table. 437 433 * 438 434 * @since 3.0.0 439 435 * @var string … … 441 437 public $signups; 442 438 443 439 /** 444 * Multisite Sites table 440 * Multisite Sites table. 445 441 * 446 442 * @since 3.0.0 447 443 * @var string … … 449 445 public $site; 450 446 451 447 /** 452 * Multisite Sitewide Terms table 448 * Multisite Sitewide Terms table. 453 449 * 454 450 * @since 3.0.0 455 451 * @var string … … 457 453 public $sitecategories; 458 454 459 455 /** 460 * Multisite Site Metadata table 456 * Multisite Site Metadata table. 461 457 * 462 458 * @since 3.0.0 463 459 * @var string … … 480 476 public $field_types = array(); 481 477 482 478 /** 483 * Database table columns charset 479 * Database table columns charset. 484 480 * 485 481 * @since 2.2.0 486 482 * @var string … … 488 484 public $charset; 489 485 490 486 /** 491 * Database table columns collate 487 * Database table columns collate. 492 488 * 493 489 * @since 2.2.0 494 490 * @var string … … 496 492 public $collate; 497 493 498 494 /** 499 * Database Username 495 * Database Username. 500 496 * 501 497 * @since 2.9.0 502 498 * @var string … … 504 500 protected $dbuser; 505 501 506 502 /** 507 * Database Password 503 * Database Password. 508 504 * 509 505 * @since 3.1.0 510 506 * @var string … … 512 508 protected $dbpassword; 513 509 514 510 /** 515 * Database Name 511 * Database Name. 516 512 * 517 513 * @since 3.1.0 518 514 * @var string … … 520 516 protected $dbname; 521 517 522 518 /** 523 * Database Host 519 * Database Host. 524 520 * 525 521 * @since 3.1.0 526 522 * @var string … … 528 524 protected $dbhost; 529 525 530 526 /** 531 * Database Handle 527 * Database Handle. 532 528 * 533 529 * @since 0.71 534 530 * @var string … … 536 532 protected $dbh; 537 533 538 534 /** 539 * A textual description of the last query/get_row/get_var call 535 * A textual description of the last query/get_row/get_var call. 540 536 * 541 537 * @since 3.0.0 542 538 * @var string … … 572 568 ); 573 569 574 570 /** 575 * Whether to use mysqli over mysql. 571 * Whether to use mysqli over mysql. Default is false. 576 572 * 577 573 * @since 3.9.0 578 574 * @var bool … … 580 576 private $use_mysqli = false; 581 577 582 578 /** 583 * Whether we've managed to successfully connect at some point 579 * Whether we've managed to successfully connect at some point. 584 580 * 585 581 * @since 3.9.0 586 582 * @var bool … … 588 584 private $has_connected = false; 589 585 590 586 /** 591 * Connects to the database server and selects a database 587 * Connects to the database server and selects a database. 592 588 * 593 * PHP5 style constructor for compatibility with PHP5. Does 594 * the actual setting up of the class properties and connection 595 * to the database. 589 * PHP5 style constructor for compatibility with PHP5. Does the actual setting up of the class properties and 590 * connection to the database. 596 591 * 597 592 * @link https://core.trac.wordpress.org/ticket/3354 598 593 * @since 2.0.8 … … 599 594 * 600 595 * @global string $wp_version The WordPress version string. 601 596 * 602 * @param string $dbuser MySQL database user 603 * @param string $dbpassword MySQL database password 604 * @param string $dbname MySQL database name 605 * @param string $dbhost MySQL database host 597 * @param string $dbuser MySQL database user. 598 * @param string $dbpassword MySQL database password. 599 * @param string $dbname MySQL database name. 600 * @param string $dbhost MySQL database host. 606 601 */ 607 602 public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) { 608 603 if ( WP_DEBUG && WP_DEBUG_DISPLAY ) { … … 636 631 * 637 632 * @since 3.5.0 638 633 * 639 * @param string $name The private member to get, and optionally process 640 * @return mixed The private member634 * @param string $name The private member to get, and optionally process. 635 * @return mixed The private member. 641 636 */ 642 637 public function __get( $name ) { 643 638 if ( 'col_info' === $name ) { … … 652 647 * 653 648 * @since 3.5.0 654 649 * 655 * @param string $name The private member to set 656 * @param mixed $value The value to set 650 * @param string $name The private member to set. 651 * @param mixed $value The value to set. 657 652 */ 658 653 public function __set( $name, $value ) { 659 654 $protected_members = array( … … 672 667 * 673 668 * @since 3.5.0 674 669 * 675 * @param string $name The private member to check 670 * @param string $name The private member to check. 676 671 * 677 * @return bool If the member is set or not672 * @return bool If the member is set or not. 678 673 */ 679 674 public function __isset( $name ) { 680 675 return isset( $this->$name ); … … 773 768 * 774 769 * @since 3.1.0 775 770 * 776 * @param resource $dbh The resource given by mysql_connect 771 * @param resource $dbh The resource given by mysql_connect. 777 772 * @param string $charset Optional. The character set. Default null. 778 773 * @param string $collate Optional. The collation. Default null. 779 774 */ … … 817 812 /** 818 813 * Change the current SQL mode, and ensure its WordPress compatibility. 819 814 * 820 * If no modes are passed, it will ensure the current MySQL server 821 * modes are compatible. 815 * If no modes are passed, it will ensure the current MySQL server modes are compatible. 822 816 * 823 817 * @since 3.9.0 824 818 * … … 886 880 * 887 881 * @param string $prefix Alphanumeric name for the new prefix. 888 882 * @param bool $set_table_names Optional. Whether the table names, e.g. wpdb::$posts, should be updated or not. 889 * @return string|WP_Error Old prefix or WP_Error on error883 * @return string|WP_Error Old prefix or WP_Error on error. 890 884 */ 891 885 public function set_prefix( $prefix, $set_table_names = true ) { 892 886 … … 931 925 * 932 926 * @param int $blog_id 933 927 * @param int $network_id Optional. 934 * @return int previous blog id928 * @return int previous blog id. 935 929 */ 936 930 public function set_blog_id( $blog_id, $network_id = 0 ) { 937 931 if ( ! empty( $network_id ) ) { … … 959 953 * 960 954 * @since 3.0.0 961 955 * @param int $blog_id Optional. 962 * @return string Blog prefix.956 * @return string Blog prefix. 963 957 */ 964 958 public function get_blog_prefix( $blog_id = null ) { 965 959 if ( is_multisite() ) { … … 980 974 /** 981 975 * Returns an array of WordPress tables. 982 976 * 983 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to 984 * override the WordPress users and usermeta tables that would otherwise 985 * be determined by the prefix. 977 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to override the WordPress users and usermeta 978 * tables that would otherwise be determined by the prefix. 986 979 * 987 * The scope argument can take one of the following:980 * The $scope argument can take one of the following: 988 981 * 989 982 * 'all' - returns 'all' and 'global' tables. No old tables are returned. 990 983 * 'blog' - returns the blog-level tables for the queried blog. … … 1002 995 * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog 1003 996 * prefix is requested, then the custom users and usermeta tables will be mapped. 1004 997 * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb::$blogid. Used only when prefix is requested. 1005 * @return array Table names. When a prefix is requested, the key is the unprefixed table name.998 * @return array Table names. When a prefix is requested, the key is the unprefixed table name. 1006 999 */ 1007 1000 public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) { 1008 1001 switch ( $scope ) { … … 1062 1055 /** 1063 1056 * Selects a database using the current database connection. 1064 1057 * 1065 * The database name will be changed based on the current database 1066 * connection. On failure, the execution will bail and display anDB error.1058 * The database name will be changed based on the current database connection. On failure, the execution will 1059 * bail and display a DB error. 1067 1060 * 1068 1061 * @since 0.71 1069 1062 * … … 1149 1142 * @see mysql_real_escape_string() 1150 1143 * @since 2.8.0 1151 1144 * 1152 * @param string $string to escape1153 * @return string escaped1145 * @param string $string String to escape. 1146 * @return string Escaped string. 1154 1147 */ 1155 1148 function _real_escape( $string ) { 1156 1149 if ( $this->dbh ) { … … 1177 1170 * Escape data. Works on arrays. 1178 1171 * 1179 1172 * @uses wpdb::_real_escape() 1180 * @since 2.8.01173 * @since 2.8.0 1181 1174 * 1182 * @param string|array $data 1183 * @return string|array escaped1175 * @param string|array $data Data to escape. 1176 * @return string|array Escaped data, in the same type as supplied. 1184 1177 */ 1185 1178 public function _escape( $data ) { 1186 1179 if ( is_array( $data ) ) { … … 1231 1224 } 1232 1225 1233 1226 /** 1234 * Escapes content by reference for insertion into the database, for security 1227 * Escapes content by reference for insertion into the database, for security. 1235 1228 * 1236 1229 * @uses wpdb::_real_escape() 1237 1230 * 1238 1231 * @since 2.3.0 1239 1232 * 1240 * @param string $string to escape1233 * @param string $string String to escape. 1241 1234 */ 1242 1235 public function escape_by_ref( &$string ) { 1243 1236 if ( ! is_float( $string ) ) { … … 1246 1239 } 1247 1240 1248 1241 /** 1249 * Prepares a SQL query for safe execution. Uses sprintf()-like syntax.1242 * Prepares a SQL query for safe execution. 1250 1243 * 1251 * The following placeholders can be used in the query string:1244 * Uses sprintf()-like syntax. The following placeholders can be used in the query string: 1252 1245 * %d (integer) 1253 1246 * %f (float) 1254 1247 * %s (string) 1255 1248 * 1256 * All placeholders MUST be left unquoted in the query string. A corresponding argument 1257 * MUST be passed for eachplaceholder.1249 * All placeholders MUST be left unquoted in the query string. A corresponding argument MUST be passed for each 1250 * placeholder. 1258 1251 * 1259 * For compatibility with old behavior, numbered or formatted string placeholders (eg, %1$s, %5s)1260 * will not have quotes added by this function, so should be passed with appropriate quotes around1261 * them for your usage.1252 * Note: There is one exception to the above: for compatibility with old behavior, older-style numbered or formatted 1253 * string placeholders (eg, %1$s, %5s) will not have quotes added by this function, so should be passed with 1254 * appropriate quotes around them. 1262 1255 * 1263 1256 * Literal percentage signs (%) in the query string must be written as %%. Percentage wildcards (for example, 1264 1257 * to use in LIKE syntax) must be passed via a substitution argument containing the complete LIKE string, these 1265 1258 * cannot be inserted directly in the query string. Also see wpdb::esc_like(). 1266 1259 * 1267 * Arguments may be passed as individual arguments to the method, or as a single array containing 1268 * all arguments.A combination of the two is not supported.1260 * Arguments may be passed as individual arguments to the method, or as a single array containing all arguments. 1261 * A combination of the two is not supported. 1269 1262 * 1270 1263 * Examples: 1271 1264 * $wpdb->prepare( "SELECT * FROM `table` WHERE `column` = %s AND `field` = %d OR `other_field` LIKE %s", array( 'foo', 1337, '%bar' ) ); … … 1277 1270 * by updating the function signature. The second parameter was changed 1278 1271 * from `$args` to `...$args`. 1279 1272 * 1280 * @param string $query Query statement with sprintf()-like placeholders 1281 * @param array|mixed $args The array of variables to substitute into the query's placeholders 1282 * if being called with an array of arguments, or the first variable 1283 * to substitute into the query's placeholders if being called with 1273 * @param string $query Query statement with sprintf()-like placeholders. 1274 * @param array|mixed $args The array of variables to substitute into the query's placeholders if being called 1275 * with an array of arguments, or the first variable to substitute into the query's 1276 * placeholders if being called with individual arguments. 1277 * @param mixed ...$args Further variables to substitute into the query's placeholders if being called with 1284 1278 * individual arguments. 1285 * @param mixed ...$args Further variables to substitute into the query's placeholders 1286 * if being called with individual arguments. 1287 * @return string|void Sanitized query string, if there is a query to prepare. 1279 * 1280 * @return string|void Sanitized query string, if there is a query to prepare. 1288 1281 */ 1289 1282 public function prepare( $query, ...$args ) { 1290 1283 if ( is_null( $query ) ) { … … 1412 1405 * 1413 1406 * @param string $text The raw text to be escaped. The input typed by the user should have no 1414 1407 * extra or deleted slashes. 1415 * @return string Text in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare()1416 * or real_escape next.1408 * @return string Text in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare() 1409 * or real_escape next. 1417 1410 */ 1418 1411 public function esc_like( $text ) { 1419 1412 return addcslashes( $text, '_%\\' ); … … 1423 1416 * Print SQL/DB error. 1424 1417 * 1425 1418 * @since 0.71 1426 * @global array $EZSQL_ERROR Stores error information of query and error string .1419 * @global array $EZSQL_ERROR Stores error information of query and error string 1427 1420 * 1428 * @param string $str The error to display .1421 * @param string $str The error to display 1429 1422 * @return void|false Void if the showing of errors is enabled, false if disabled. 1430 1423 */ 1431 1424 public function print_error( $str = '' ) { … … 1496 1489 /** 1497 1490 * Enables showing of database errors. 1498 1491 * 1499 * This function should be used only to enable showing of errors. 1500 * wpdb::hide_errors() should be used instead for hiding of errors. However, 1501 * this function can be used to enable and disable showing of database 1502 * errors. 1492 * This function should be used only to enable showing of errors. wpdb::hide_errors() should be used instead for 1493 * hiding of errors. However, this function can be used to enable and disable showing of database errors. 1503 1494 * 1495 * @see wpdb::hide_errors() 1496 * 1504 1497 * @since 0.71 1505 1498 * @see wpdb::hide_errors() 1506 1499 * 1507 * @param bool $show Whether to show or hide errors 1508 * @return bool Old value for showing errors.1500 * @param bool $show Whether to show or hide errors. 1501 * @return bool Whether showing of errors was previously active. 1509 1502 */ 1510 1503 public function show_errors( $show = true ) { 1511 1504 $errors = $this->show_errors; … … 1521 1514 * @since 0.71 1522 1515 * @see wpdb::show_errors() 1523 1516 * 1524 * @return bool Whether showing of errors was active1517 * @return bool Whether showing of errors was previously active. 1525 1518 */ 1526 1519 public function hide_errors() { 1527 1520 $show = $this->show_errors; … … 1532 1525 /** 1533 1526 * Whether to suppress database errors. 1534 1527 * 1535 * By default database errors are suppressed, with a simple 1536 * call to this function they can be enabled. 1528 * By default database errors are suppressed, with a simple call to this function they can be enabled. 1537 1529 * 1538 1530 * @since 2.5.0 1539 1531 * @see wpdb::hide_errors() 1532 * 1540 1533 * @param bool $suppress Optional. New value. Defaults to true. 1541 1534 * @return bool Old value 1542 1535 */ … … 1580 1573 /** 1581 1574 * Connect to and select database. 1582 1575 * 1583 * If $allow_bail is false, the lack of database connection will need 1584 * to be handled manually. 1576 * If $allow_bail is false, the lack of database connection will need to be handled manually. 1585 1577 * 1586 1578 * @since 3.0.0 1587 1579 * @since 3.9.0 $allow_bail parameter added. 1588 1580 * 1589 1581 * @param bool $allow_bail Optional. Allows the function to bail. Default true. 1590 * @return bool True with a successful connection, false on failure.1582 * @return bool True with a successful connection, false on failure. 1591 1583 */ 1592 1584 public function db_connect( $allow_bail = true ) { 1593 1585 $this->is_mysql = true; … … 1717 1709 /** 1718 1710 * Parse the DB_HOST setting to interpret it for mysqli_real_connect. 1719 1711 * 1720 * mysqli_real_connect doesn't support the host param including a port or 1721 * socket like mysql_connect does. This duplicates how mysql_connect detects 1722 * a port and/or socket file. 1712 * mysqli_real_connect doesn't support the host param including a port or socket like mysql_connect does. This 1713 * duplicates how mysql_connect detects a port and/or socket file. 1723 1714 * 1724 1715 * @since 4.9.0 1725 1716 * … … 1771 1762 /** 1772 1763 * Checks that the connection to the database is still up. If not, try to reconnect. 1773 1764 * 1774 * If this function is unable to reconnect, it will forcibly die, or if after the 1775 * the {@see 'template_redirect'} hookhas been fired, return false instead.1765 * If this function is unable to reconnect, it will forcibly die, or if after the {@see 'template_redirect'} hook 1766 * has been fired, return false instead. 1776 1767 * 1777 * If $allow_bail is false, the lack of database connection will need 1778 * to be handled manually. 1768 * If $allow_bail is false, the lack of database connection will need to be handled manually. 1779 1769 * 1780 1770 * @since 3.9.0 1781 1771 * … … 1802 1792 } 1803 1793 1804 1794 for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) { 1805 // On the last try, re-enable warnings. We want to see a single instance 1806 // of the"unable to connect" message on the bail() screen, if it appears.1795 // On the last try, re-enable warnings. We want to see a single instance of the 1796 // "unable to connect" message on the bail() screen, if it appears. 1807 1797 if ( $this->reconnect_retries === $tries && WP_DEBUG ) { 1808 1798 error_reporting( $error_reporting ); 1809 1799 } … … 1853 1843 // We weren't able to reconnect, so we better bail. 1854 1844 $this->bail( $message, 'db_connect_fail' ); 1855 1845 1856 // Call dead_db() if bail didn't die, because this database is no more. 1857 // It has ceased to be (at least temporarily). 1846 // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily). 1858 1847 dead_db(); 1859 1848 } 1860 1849 … … 1866 1855 * @since 0.71 1867 1856 * 1868 1857 * @param string $query Database query 1869 * @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows1870 * affected/selected for all other queries. Boolean false on error.1858 * @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows 1859 * affected/selected for all other queries. Boolean false on error. 1871 1860 */ 1872 1861 public function query( $query ) { 1873 1862 if ( ! $this->ready ) { … … 1997 1986 } 1998 1987 } 1999 1988 2000 // Log number of rows the query returned 2001 // and return number of rows selected. 1989 // Log number of rows the query returned and return number of rows selected. 2002 1990 $this->num_rows = $num_rows; 2003 1991 $return_val = $num_rows; 2004 1992 } … … 2113 2101 * @since 4.8.3 2114 2102 * 2115 2103 * @param string $query The query to escape. 2116 * @return string The query with the placeholder escape string inserted where necessary.2104 * @return string The query with the placeholder escape string inserted where necessary. 2117 2105 */ 2118 2106 public function add_placeholder_escape( $query ) { 2119 2107 /* … … 2129 2117 * @since 4.8.3 2130 2118 * 2131 2119 * @param string $query The query from which the placeholder will be removed. 2132 * @return string The query with the placeholder removed.2120 * @return string The query with the placeholder removed. 2133 2121 */ 2134 2122 public function remove_placeholder_escape( $query ) { 2135 2123 return str_replace( $this->placeholder_escape(), '%', $query ); … … 2138 2126 /** 2139 2127 * Insert a row into a table. 2140 2128 * 2129 * Examples: 2141 2130 * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 'bar' ) ) 2142 2131 * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) ) 2143 2132 * … … 2146 2135 * @see wpdb::$field_types 2147 2136 * @see wp_set_wpdb_vars() 2148 2137 * 2149 * @param string $table Table name 2138 * @param string $table Table name. 2150 2139 * @param array $data Data to insert (in column => value pairs). 2151 2140 * Both $data columns and $data values should be "raw" (neither should be SQL escaped). 2152 * Sending a null value will cause the column to be set to NULL - the corresponding format is ignored in this case. 2141 * Sending a null value will cause the column to be set to NULL - the corresponding 2142 * format is ignored in this case. 2153 2143 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. 2154 2144 * If string, that format will be used for all of the values in $data. 2155 2145 * A format is one of '%d', '%f', '%s' (integer, float, string). 2156 * If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. 2157 * @return int|false The number of rows inserted, or false on error. 2146 * If omitted, all values in $data will be treated as strings unless otherwise 2147 * specified in wpdb::$field_types. 2148 * @return int|false The number of rows inserted, or false on error. 2158 2149 */ 2159 2150 public function insert( $table, $data, $format = null ) { 2160 2151 return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' ); … … 2163 2154 /** 2164 2155 * Replace a row into a table. 2165 2156 * 2157 * Examples: 2166 2158 * wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 'bar' ) ) 2167 2159 * wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) ) 2168 2160 * … … 2171 2163 * @see wpdb::$field_types 2172 2164 * @see wp_set_wpdb_vars() 2173 2165 * 2174 * @param string $table Table name 2166 * @param string $table Table name. 2175 2167 * @param array $data Data to insert (in column => value pairs). 2176 2168 * Both $data columns and $data values should be "raw" (neither should be SQL escaped). 2177 * Sending a null value will cause the column to be set to NULL - the corresponding format is ignored in this case. 2169 * Sending a null value will cause the column to be set to NULL - the corresponding 2170 * format is ignored in this case. 2178 2171 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. 2179 2172 * If string, that format will be used for all of the values in $data. 2180 2173 * A format is one of '%d', '%f', '%s' (integer, float, string). 2181 * If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. 2182 * @return int|false The number of rows affected, or false on error. 2174 * If omitted, all values in $data will be treated as strings unless otherwise 2175 * specified in wpdb::$field_types. 2176 * @return int|false The number of rows affected, or false on error. 2183 2177 */ 2184 2178 public function replace( $table, $data, $format = null ) { 2185 2179 return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' ); … … 2198 2192 * @param string $table Table name 2199 2193 * @param array $data Data to insert (in column => value pairs). 2200 2194 * Both $data columns and $data values should be "raw" (neither should be SQL escaped). 2201 * Sending a null value will cause the column to be set to NULL - the corresponding format is ignored in this case. 2195 * Sending a null value will cause the column to be set to NULL - the corresponding 2196 * format is ignored in this case. 2202 2197 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. 2203 2198 * If string, that format will be used for all of the values in $data. 2204 2199 * A format is one of '%d', '%f', '%s' (integer, float, string). 2205 * If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. 2200 * If omitted, all values in $data will be treated as strings unless otherwise 2201 * specified in wpdb::$field_types. 2206 2202 * @param string $type Optional. What type of operation is this? INSERT or REPLACE. Defaults to INSERT. 2207 2203 * @return int|false The number of rows affected, or false on error. 2208 2204 */ … … 2240 2236 } 2241 2237 2242 2238 /** 2243 * Update a row in the table 2239 * Update a row in the table. 2244 2240 * 2241 * Examples: 2245 2242 * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 'bar' ), array( 'ID' => 1 ) ) 2246 2243 * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) ) 2247 2244 * … … 2258 2255 * @param array $where A named array of WHERE clauses (in column => value pairs). 2259 2256 * Multiple clauses will be joined with ANDs. 2260 2257 * Both $where columns and $where values should be "raw". 2261 * Sending a null value will create an IS NULL comparison - the corresponding format will be ignored in this case. 2258 * Sending a null value will create an IS NULL comparison - the corresponding 2259 * format will be ignored in this case. 2262 2260 * @param array|string $format Optional. An array of formats to be mapped to each of the values in $data. 2263 2261 * If string, that format will be used for all of the values in $data. 2264 2262 * A format is one of '%d', '%f', '%s' (integer, float, string). 2265 * If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. 2263 * If omitted, all values in $data will be treated as strings unless otherwise 2264 * specified in wpdb::$field_types. 2266 2265 * @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where. 2267 2266 * If string, that format will be used for all of the items in $where. 2268 2267 * A format is one of '%d', '%f', '%s' (integer, float, string). 2269 2268 * If omitted, all values in $where will be treated as strings. 2270 * @return int|false The number of rows updated, or false on error.2269 * @return int|false The number of rows updated, or false on error. 2271 2270 */ 2272 2271 public function update( $table, $data, $where, $format = null, $where_format = null ) { 2273 2272 if ( ! is_array( $data ) || ! is_array( $where ) ) { … … 2329 2328 * @param array $where A named array of WHERE clauses (in column => value pairs). 2330 2329 * Multiple clauses will be joined with ANDs. 2331 2330 * Both $where columns and $where values should be "raw". 2332 * Sending a null value will create an IS NULL comparison - the corresponding format will be ignored in this case. 2331 * Sending a null value will create an IS NULL comparison - the corresponding 2332 * format will be ignored in this case. 2333 2333 * @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where. 2334 2334 * If string, that format will be used for all of the items in $where. 2335 2335 * A format is one of '%d', '%f', '%s' (integer, float, string). 2336 * If omitted, all values in $where will be treated as strings unless otherwise specified in wpdb::$field_types. 2337 * @return int|false The number of rows updated, or false on error. 2336 * If omitted, all values in $data will be treated as strings unless otherwise 2337 * specified in wpdb::$field_types. 2338 * @return int|false The number of rows updated, or false on error. 2338 2339 */ 2339 2340 public function delete( $table, $where, $where_format = null ) { 2340 2341 if ( ! is_array( $where ) ) { … … 2369 2370 /** 2370 2371 * Processes arrays of field/value pairs and field formats. 2371 2372 * 2372 * This is a helper method for wpdb's CRUD methods, which take field/value 2373 * pairs for inserts, updates, and where clauses. This method first pairs 2374 * each value with a format. Then it determines the charset of that field, 2375 * using that to determine if any invalid text would be stripped. If text is 2376 * stripped, then field processing is rejected and the query fails. 2373 * This is a helper method for wpdb's CRUD methods, which take field/value pairs for inserts, updates, and where 2374 * clauses. This method first pairs each value with a format. Then it determines the charset of that field, using 2375 * that to determine if any invalid text would be stripped. If text is stripped, then field processing is rejected 2376 * and the query fails. 2377 2377 * 2378 2378 * @since 4.2.0 2379 2379 * … … 2380 2380 * @param string $table Table name. 2381 2381 * @param array $data Field/value pair. 2382 2382 * @param mixed $format Format for each field. 2383 * @return array|false Returns an array of fields that contain paired values 2384 * and formats. Returns false for invalid values. 2383 * 2384 * @return array|false Returns an array of fields that contain paired value and formats. Returns false for 2385 * invalid values. 2385 2386 */ 2386 2387 protected function process_fields( $table, $data, $format ) { 2387 2388 $data = $this->process_field_formats( $data, $format ); … … 2415 2416 * 2416 2417 * @param array $data Array of fields to values. 2417 2418 * @param mixed $format Formats to be mapped to the values in $data. 2418 * @return array Array, keyed by field names with values being an array 2419 * of 'value' and 'format' keys. 2419 * @return array Array, keyed by field names with values being an array of 'value' and 'format' keys. 2420 2420 */ 2421 2421 protected function process_field_formats( $data, $format ) { 2422 2422 $formats = (array) $format; … … 2444 2444 } 2445 2445 2446 2446 /** 2447 * Adds field charsets to field/value/format arrays generated by 2448 * the wpdb::process_field_formats() method. 2447 * Adds field charsets to field/value/format arrays generated by the wpdb::process_field_formats() method. 2449 2448 * 2450 2449 * @since 4.2.0 2451 2450 * 2452 2451 * @param array $data As it comes from the wpdb::process_field_formats() method. 2453 2452 * @param string $table Table name. 2454 * @return array|false The same array as $data with additional 'charset' keys.2453 * @return array|false The same array as $data with additional 'charset' keys. 2455 2454 */ 2456 2455 protected function process_field_charsets( $data, $table ) { 2457 2456 foreach ( $data as $field => $value ) { … … 2481 2480 * 2482 2481 * @param array $data As it comes from the wpdb::process_field_charsets() method. 2483 2482 * @param string $table Table name. 2484 * @return array|false The same array as $data with additional 'length' keys, or false if2485 * any of the values were too long for their corresponding field.2483 * @return array|false The same array as $data with additional 'length' keys, or false if 2484 * any of the values were too long for their corresponding field. 2486 2485 */ 2487 2486 protected function process_field_lengths( $data, $table ) { 2488 2487 foreach ( $data as $field => $value ) { … … 2508 2507 /** 2509 2508 * Retrieve one variable from the database. 2510 2509 * 2511 * Executes a SQL query and returns the value from the SQL result. 2512 * If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified.2513 * If $query is null, this function returns the value in the specified column and row from the previous SQL result.2510 * Executes a SQL query and returns the value from the SQL result. If the SQL result contains more than one column 2511 * and/or more than one row, the value in the column and row specified is returned. If $query is null, the value 2512 * in the specified column and row from the previous SQL result is returned. 2514 2513 * 2515 2514 * @since 0.71 2516 2515 * … … 2517 2516 * @param string|null $query Optional. SQL query. Defaults to null, use the result from the previous query. 2518 2517 * @param int $x Optional. Column of value to return. Indexed from 0. 2519 2518 * @param int $y Optional. Row of value to return. Indexed from 0. 2520 * @return string|null Database query result (as string), or null on failure2519 * @return string|null Database query result (as string), or null on failure 2521 2520 */ 2522 2521 public function get_var( $query = null, $x = 0, $y = 0 ) { 2523 2522 $this->func_call = "\$db->get_var(\"$query\", $x, $y)"; … … 2546 2545 * 2547 2546 * @since 0.71 2548 2547 * 2549 * @param string|null $query SQL query. 2550 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to 2551 * an stdClass object, an associative array, or a numeric array, respectively. Default OBJECT. 2552 * @param int $y Optional. Row to return. Indexed from 0. 2548 * @param string|null $query SQL query. 2549 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which 2550 * correspond to a stdClass object, an associative array, or a numeric array, 2551 * respectively. Default OBJECT. 2552 * @param int $y Optional. Row to return. Indexed from 0. 2553 2553 * @return array|object|null|void Database query result in format specified by $output or null on failure 2554 2554 */ 2555 2555 public function get_row( $query = null, $output = OBJECT, $y = 0 ) { … … 2586 2586 /** 2587 2587 * Retrieve one column from the database. 2588 2588 * 2589 * Executes a SQL query and returns the column from the SQL result. 2590 * If the SQL result contains more than one column, this function returns the column specified.2591 * If $query is null, this function returns the specified column fromthe previous SQL result.2589 * Executes a SQL query and returns the column from the SQL result. If the SQL result contains more than one column, 2590 * this function returns the column specified. If $query is null, this function returns the specified column from 2591 * the previous SQL result. 2592 2592 * 2593 2593 * @since 0.71 2594 2594 * 2595 2595 * @param string|null $query Optional. SQL query. Defaults to previous query. 2596 2596 * @param int $x Optional. Column to return. Indexed from 0. 2597 * @return array Database query result. Array indexed from 0 by SQL result row number.2597 * @return array Database query result. Array indexed from 0 by SQL result row number. 2598 2598 */ 2599 2599 public function get_col( $query = null, $x = 0 ) { 2600 2600 if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { … … 2622 2622 * 2623 2623 * @since 0.71 2624 2624 * 2625 * @param string $query SQL query. 2626 * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. 2627 * With one of the first three, return an array of rows indexed from 0 by SQL result row number. 2628 * Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively. 2629 * With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value. 2630 * Duplicate keys are discarded. 2631 * @return array|object|null Database query results 2625 * @param string $query SQL query. 2626 * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. 2627 * With one of the first three, return an array of rows indexed from 0 by SQL result row 2628 * number. Each row is an associative array (column => value, ...), a numerically indexed 2629 * array (0 => value, ...), or an object. ( ->column = value ), respectively. With 2630 * OBJECT_K, return an associative array of row objects keyed by the value of each row's 2631 * first column's value. Duplicate keys are discarded. 2632 * @return array|object|null Database query results. 2633 * 2632 2634 */ 2633 2635 public function get_results( $query = null, $output = OBJECT ) { 2634 2636 $this->func_call = "\$db->get_results(\"$query\", $output)"; … … 2686 2688 * 2687 2689 * @since 4.2.0 2688 2690 * 2689 * @param string $table Table name.2691 * @param string $table Table name. 2690 2692 * @return string|WP_Error Table character set, WP_Error object if it couldn't be found. 2691 2693 */ 2692 2694 protected function get_table_charset( $table ) { … … 2787 2789 * 2788 2790 * @since 4.2.0 2789 2791 * 2790 * @param string $table Table name.2791 * @param string $column Column name.2792 * @return string|false|WP_Error Column character set as a string. False if the column has no 2793 * character set.WP_Error object if there was an error.2792 * @param string $table Table name. 2793 * @param string $column Column name. 2794 * @return string|false|WP_Error Column character set as a string. False if the column has no character set. 2795 * WP_Error object if there was an error. 2794 2796 */ 2795 2797 public function get_col_charset( $table, $column ) { 2796 2798 $tablekey = strtolower( $table ); … … 2847 2849 2848 2850 /** 2849 2851 * Retrieve the maximum string length allowed in a given column. 2852 * 2850 2853 * The length may either be specified as a byte length or a character length. 2851 2854 * 2852 2855 * @since 4.2.1 2853 2856 * 2854 * @param string $table Table name.2855 * @param string $column Column name.2857 * @param string $table Table name. 2858 * @param string $column Column name. 2856 2859 * @return array|false|WP_Error array( 'length' => (int), 'type' => 'byte' | 'char' ) 2857 2860 * false if the column has no length (for example, numeric column) 2858 2861 * WP_Error object if there was an error. … … 2938 2941 /** 2939 2942 * Check if a string is ASCII. 2940 2943 * 2941 * The negative regex is faster for non-ASCII strings, as it allows 2942 * the search to finish as soon as it encountersa non-ASCII character.2944 * The negative regex is faster for non-ASCII strings, as it allows the search to finish as soon as it encounters 2945 * a non-ASCII character. 2943 2946 * 2944 2947 * @since 4.2.0 2945 2948 * 2946 2949 * @param string $string String to check. 2947 * @return bool True if ASCII, false if not.2950 * @return bool True if ASCII, false if not. 2948 2951 */ 2949 2952 protected function check_ascii( $string ) { 2950 2953 if ( function_exists( 'mb_check_encoding' ) ) { … … 2964 2967 * @since 4.2.0 2965 2968 * 2966 2969 * @param string $query The query to check. 2967 * @return bool True if the collation is safe, false if it isn't.2970 * @return bool True if the collation is safe, false if it isn't. 2968 2971 */ 2969 2972 protected function check_safe_collation( $query ) { 2970 2973 if ( $this->checking_collation ) { … … 3020 3023 * 3021 3024 * @since 4.2.0 3022 3025 * 3023 * @param array $data Array of value arrays. Each value array has the keys 3024 * 'value' and 'charset'. An optional 'ascii' key can be 3025 * set to false to avoid redundant ASCII checks. 3026 * @return array|WP_Error The $data parameter, with invalid characters removed from 3027 * each value. This works as a passthrough: any additional keys 3028 * such as 'field' are retained in each value array. If we cannot 3029 * remove invalid characters, a WP_Error object is returned. 3026 * @param array $data Array of value arrays. Each value array has the keys 'value' and 'charset'. An optional 3027 * 'ascii' key can be set to false to avoid redundant ASCII checks. 3028 * @return array|WP_Error The $data parameter, with invalid characters removed from each value. This works as a 3029 * passthrough: any additional keys such as 'field' are retained in each value array. If we 3030 * cannot remove invalid characters, a WP_Error object is returned. 3030 3031 */ 3031 3032 protected function strip_invalid_text( $data ) { 3032 3033 $db_check_string = false; … … 3039 3040 $truncate_by_byte_length = 'byte' === $value['length']['type']; 3040 3041 } else { 3041 3042 $length = false; 3042 /* 3043 * Since we have no length, we'll never truncate. 3044 * Initialize the variable to false. true would take us 3045 * through an unnecessary (for this case) codepath below. 3046 */ 3043 // Since we have no length, we'll never truncate. Initialize the variable to false. true would take us 3044 // through an unnecessary (for this case) codepath below. 3047 3045 $truncate_by_byte_length = false; 3048 3046 } 3049 3047 … … 3059 3057 3060 3058 $needs_validation = true; 3061 3059 if ( 3062 // latin1 can store any byte sequence 3060 // latin1 can store any byte sequence. 3063 3061 'latin1' === $charset 3064 3062 || 3065 3063 // ASCII is always OK. … … 3182 3180 * 3183 3181 * @since 4.2.0 3184 3182 * 3185 * @param string $query Query to convert.3183 * @param string $query Query to convert. 3186 3184 * @return string|WP_Error The converted query, or a WP_Error object if the conversion fails. 3187 3185 */ 3188 3186 protected function strip_invalid_text_from_query( $query ) { … … 3227 3225 * 3228 3226 * @since 4.2.0 3229 3227 * 3230 * @param string $table Table name.3231 * @param string $column Column name.3232 * @param string $value The text to check.3228 * @param string $table Table name. 3229 * @param string $column Column name. 3230 * @param string $value The text to check. 3233 3231 * @return string|WP_Error The converted string, or a WP_Error object if the conversion fails. 3234 3232 */ 3235 3233 public function strip_invalid_text_for_column( $table, $column, $value ) { … … 3302 3300 3303 3301 /* 3304 3302 * SHOW TABLE STATUS LIKE and SHOW TABLES LIKE 'wp\_123\_%' 3305 * This quoted LIKE operand seldom holds a full table name. 3306 * It is usually a pattern for matching a prefix so we just 3307 * strip the trailing % and unescape the _ to get 'wp_123_' 3308 * which drop-ins can use for routing these SQL statements. 3303 * This quoted LIKE operand seldom holds a full table name. It is usually a 3304 * pattern for matching a prefix so we just strip the trailing % and unescape 3305 * the _ to get 'wp_123_' which drop-ins can use for routing these SQL statements. 3309 3306 */ 3310 3307 if ( preg_match( '/^\s*SHOW\s+(?:TABLE\s+STATUS|(?:FULL\s+)?TABLES)\s+(?:WHERE\s+Name\s+)?LIKE\s*("|\')((?:[\\\\0-9a-zA-Z$_.-]|[\xC2-\xDF][\x80-\xBF])+)%?\\1/is', $query, $maybe ) ) { 3311 3308 return str_replace( '\\_', '_', $maybe[2] ); … … 3365 3362 * 3366 3363 * @since 0.71 3367 3364 * 3368 * @param string $info_type Optional. Type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill 3369 * @param int $col_offset Optional. 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type 3365 * @param string $info_type Optional. Type one of name, table, def, max_length, not_null, primary_key, 3366 * multiple_key, unique_key, numeric, blob, type, unsigned, zerofill 3367 * @param int $col_offset Optional. 0: col name. 1: which table the col's in. 2: col's max length. 3368 * 3: if the col is numeric. 4: col's type 3370 3369 * @return mixed Column Results 3371 3370 */ 3372 3371 public function get_col_info( $info_type = 'name', $col_offset = -1 ) { … … 3417 3416 * 3418 3417 * @since 1.5.0 3419 3418 * 3420 * @param string $message The error message.3421 * @param string $error_code Optional. A computer-readable string to identify the error.3422 * @return void|false Void if the showing of errors is enabled, false if disabled.3419 * @param string $message The Error message 3420 * @param string $error_code Optional. A Computer readable string to identify the error. 3421 * @return false|void 3423 3422 */ 3424 3423 public function bail( $message, $error_code = '500' ) { 3425 3424 if ( $this->show_errors ) { … … 3461 3460 * 3462 3461 * @since 4.5.0 3463 3462 * 3464 * @return bool True if the connection was successfully closed, false if it wasn't, 3465 * or the connection doesn't exist. 3463 * @return bool True if the connection was successfully closed, false if it wasn't, or if the connection doesn't exist. 3466 3464 */ 3467 3465 public function close() { 3468 3466 if ( ! $this->dbh ) { … … 3489 3487 * 3490 3488 * @since 2.5.0 3491 3489 * 3492 * @global string $wp_version The WordPress version string. 3493 * @global string $required_mysql_version The required MySQL version string. 3494 * 3495 * @return void|WP_Error 3490 * @global string $wp_version 3491 * @global string $required_mysql_version 3492 * @return WP_Error|void 3496 3493 */ 3497 3494 public function check_database_version() { 3498 3495 global $wp_version, $required_mysql_version; … … 3549 3546 * 3550 3547 * @see wpdb::db_version() 3551 3548 * 3552 * @param string $db_cap The feature to check for. Accepts 'collation', 3553 * 'group_concat', 'subqueries', 'set_charset', 3549 * @param string $db_cap The feature to check for. Accepts 'collation', 'group_concat', 'subqueries', 'set_charset', 3554 3550 * 'utf8mb4', or 'utf8mb4_520'. 3555 * @return int|false Whether the database feature is supported, false otherwise.3551 * @return int|false Whether the database feature is supported, false otherwise. 3556 3552 */ 3557 3553 public function has_cap( $db_cap ) { 3558 3554 $version = $this->db_version(); … … 3594 3590 /** 3595 3591 * Retrieve the name of the function that called wpdb. 3596 3592 * 3597 * Searches up the list of functions until it reaches 3598 * the one that would most logically had called this method. 3593 * Searches up the list of functions until it reaches the one that would most logically had called this method. 3599 3594 * 3600 3595 * @since 2.5.0 3601 3596 *