Last active
December 17, 2015 05:08
-
-
Save jonathandavis/5555308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Provides the installed database schema version from the database (if available) | |
* | |
* Queries the database to get the installed database version number. If not available, | |
* also checks the legacy | |
* | |
* @author Jonathan Davis | |
* @since 1.3 | |
* | |
* @param string $legacy Set to anything but boolean false to attempt to lookup the version from the pre-1.2 settings table | |
* @return integer The installed database schema version number (0 means not installed) | |
**/ | |
public static function dbversion ( $legacy = false ) { | |
$source = $legacy ? 'setting' : self::$table; | |
$table = DatabaseObject::tablename($source); | |
$version = DB::query("SELECT value FROM $table WHERE name='db_version'", 'col'); | |
// Try again using the legacy table | |
if ( false === $version && false === $legacy ) $version = self::dbversion('legacy'); | |
return (int)$version; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment