Suggested Method For Choosing Between SQL Server 2000 and 2005/2008

Events happening in the community are now at Drupal community events on www.drupal.org.
pcorbett's picture

I have been working to get SQL Server 2000 to work with Drupal 5.3. Everything seems to be working except for a small pagination issue. As part of this, I have been prepping it for use with 2005/2008 as well, but wanted to share with the group to see if we should agree upon a common way to distinguish between different versions (since syntax and functions vary so much between them). I am assuming that there will be differences between 2005 and 2008 that we may have to account for, so this doesn't have to be 2000 vs. 2005-specific.

Here is how I modified the db_version() function in database.mssql.inc:

/**
* Returns the version of the database server currently in use.
*
* @return Database server version
*/
function db_version() {
  $version = db_result(db_query('SELECT @@version;'));
  list($version) = explode('-', $version);
  (strpos($version, '2000')) ? $version = 2000 : $version = 2005;  
   return $version;
}

In practice, it looks something like this:

switch ($GLOBALS['db_type']) {
  case 'mssql':
    if (db_version() == '2000') {
      ...
    }
    ...
    break;
  }
}

Let me know what you think. I all for helping out with this as much as I can, but definitely don't want to have to back-pedal if the group decides to do this a different way.

Comments

looks reasonable

moshe weitzman's picture

looks ok to me. if we want db_version to work for other drivers, it should probably return mssql as well ... thanks for working on this important project, pcorbett

oops

moshe weitzman's picture

it already is in other drivers. your version looks grand.

Enterprise

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: