下面是源代码中wpdb类的构造函数。根据谷歌搜索,这一名称最近已从USE\\u EXT\\u MYSQL重命名。然而,我在源代码中找不到任何定义了常量的地方。
function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
register_shutdown_function( array( $this, \'__destruct\' ) );
if ( WP_DEBUG && WP_DEBUG_DISPLAY )
$this->show_errors();
/* Use ext/mysqli if it exists and:
* - WP_USE_EXT_MYSQL is defined as false, or
* - We are a development version of WordPress, or
* - We are running PHP 5.5 or greater, or
* - ext/mysql is not loaded.
*/
if ( function_exists( \'mysqli_connect\' ) ) {
if ( defined( \'WP_USE_EXT_MYSQL\' ) ) {
$this->use_mysqli = ! WP_USE_EXT_MYSQL;
} elseif ( version_compare( phpversion(), \'5.5\', \'>=\' ) || ! function_exists( \'mysql_connect\' ) ) {
$this->use_mysqli = true;
} elseif ( false !== strpos( $GLOBALS[\'wp_version\'], \'-\' ) ) {
$this->use_mysqli = true;
}
}
有人能给我解释一下代码的作用,以及是否有遗漏?
谢谢