March 2011
Beginner to intermediate
300 pages
7h 23m
English
It's the same pattern to test the database version, but we rely on the global $wbdb object and its get_results method. We are using a simple MySQL statement: 'SELECT VERSION()' to return the MySQL version. (The 'as ver' part of the query merely specifies how MySQL should name that particular column in its results).
// INPUT: minimum req'd version of MySQL, e.g. 5.0.41
public static function mysql_version_gt($ver)
{
global $wpdb;
$exit_msg = CustomPostTypeManager::name . __( " requires MySQL $ver or newer.
Talk to your system administrator about upgrading");
$result = $wpdb->get_results( 'SELECT VERSION() as ver' );
if ( version_compare( $result[0]->ver, $ver, '<') )
{
self::$errors[] = $exit_msg;
}
}Read now
Unlock full access