O'Reilly logo

WordPress 3 Plugin Development Essentials by Everett Griffiths, Brian Bondari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing MySQL version

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;
}
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required