本文整理汇总了PHP中wpdb::db_version方法的典型用法代码示例。如果您正苦于以下问题:PHP wpdb::db_version方法的具体用法?PHP wpdb::db_version怎么用?PHP wpdb::db_version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpdb
的用法示例。
在下文中一共展示了wpdb::db_version方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connectDatabase
/**
* connectDatabase()
*
* Initializes a connection to the mysql database.
* REQUIRES: databaseSettings portion of state to be set.
*
* @return boolean True on success; else false. Success testing is very loose.
*/
function connectDatabase()
{
$this->_before(__FUNCTION__);
global $wpdb;
$wpdb = new wpdb($this->_state['databaseSettings']['username'], $this->_state['databaseSettings']['password'], $this->_state['databaseSettings']['database'], $this->_state['databaseSettings']['server']);
// See if we have a specified character set and collation to use from the source site.
$charset = null;
$collate = null;
if (isset($this->_state['dat']['db_charset'])) {
$charset = $this->_state['dat']['db_charset'];
}
if (isset($this->_state['dat']['db_collate'])) {
$collate = $this->_state['dat']['db_collate'];
}
if (null !== $charset || null !== $collate) {
pb_backupbuddy::status('details', 'Setting charset to `' . $charset . '` and collate to `' . $collate . '` based on source site.');
$wpdb->set_charset($wpdb->dbh, $charset, $collate);
} else {
pb_backupbuddy::status('details', 'Charset nor collate are in DAT file. Using defaults for database connection.');
pb_backupbuddy::status('details', 'Charset in wpdb: ' . $wpdb->charset);
}
// Warn if mysql versions are incompatible; eg importing a mysql < 5.1 version into a server running 5.1+.
global $wpdb;
if (isset($this->_state['dat']['db_version'])) {
$incomingVersion = $this->_state['dat']['db_version'];
}
$thisVersion = $wpdb->db_version();
pb_backupbuddy::status('details', 'Incoming mysql version: `' . $incomingVersion . '`. This server\'s mysql version: `' . $thisVersion . '`.');
if (version_compare($incomingVersion, '5.1.0', '<') && version_compare($thisVersion, '5.1.0', '>=')) {
pb_backupbuddy::status('warning', 'Error #7001: This server\'s mysql version, `' . $thisVersion . '` may have SQL query incompatibilities with the backup mysql version `' . $incomingVersion . '`. This may result in #9010 errors due to syntax of TYPE= changing to ENGINE=. If none occur you may ignore this error.');
}
return true;
}
示例2: phpversion
function get_system_data()
{
global $wp_version;
$php = phpversion();
$maxMemLimit = ini_get('memory_limit');
$extensions = implode(', ', get_loaded_extensions());
$disabledFunctions = ini_get('disable_functions');
$maxExTime = ini_get('max_execution_time');
$upMaxExTime = 0;
$newMaxExTime = intval($maxExTime) + 60;
@set_time_limit($newMaxExTime);
if (ini_get('max_execution_time') == $newMaxExTime) {
$upMaxExTime = 1;
$maxExTime = ini_get('max_execution_time');
}
$mysql = '';
if (!class_exists('wpdb')) {
require_once ABSPATH . '/' . WPINC . '/wp-db.php';
}
$mysqli = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$errors = $mysqli->last_error;
if (empty($errors)) {
$mysql = $mysqli->db_version();
}
$upMemLimit = 0;
$newMemLimit = intval($maxMemLimit) + 60;
ini_set('memory_limit', $newMemLimit . 'M');
if (ini_get('memory_limit') == $newMemLimit) {
$upMemLimit = 1;
$maxMemLimit = ini_get('memory_limit');
}
$extensions_s = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
$disabledFunctions_s = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
$ext = comparison_function($extensions, $extensions_s);
$function = comparison_function($disabledFunctions, $disabledFunctions_s, true);
return array('wp_version' => $wp_version, 'wp_lang' => get_option('WPLANG'), 'php_verion' => $php, 'maxExecutionTime' => $maxExTime, 'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions, 'mysqlVersion' => $mysql, 'upMaxExecutionTime' => $upMaxExTime, 'newMaxExecutionTime' => $newMaxExTime, 'upMemoryLimit' => $upMemLimit, 'newMemoryLimit' => $newMemLimit, 'maxMemoryLimit' => $maxMemLimit, 'ex' => $ext, 'func' => $function);
}