BUGFIX MSSQLDatabase::fullTextEnabled() should be cached so it doesn't have to query it all the time and slow down the database when dev/build occurs

This commit is contained in:
Sean Harvey 2010-02-23 01:23:42 +00:00
parent 5667388908
commit d09acc0cbe

View File

@ -55,6 +55,14 @@ class MSSQLDatabase extends SS_Database {
protected $supportsTransactions = false;
/**
* Cached flag to determine if full-text is enabled. This is set by
* {@link MSSQLDatabase::fullTextEnabled()}
*
* @var boolean
*/
protected $fullTextEnabled = null;
/**
* Connect to a MS SQL database.
* @param array $parameters An map of parameters, which should include:
@ -117,13 +125,16 @@ class MSSQLDatabase extends SS_Database {
* @return boolean
*/
public function fullTextEnabled() {
if($this->fullTextEnabled === null) {
$isInstalled = (boolean) DB::query("SELECT fulltextserviceproperty('isfulltextinstalled')")->value();
$enabledForDb = (boolean) DB::query("
SELECT is_fulltext_enabled
FROM sys.databases
WHERE name = '$this->database'
")->value();
return $isInstalled && $enabledForDb;
$this->fullTextEnabled = ($isInstalled && $enabledForDb);
}
return $this->fullTextEnabled;
}
/**
@ -304,7 +315,7 @@ class MSSQLDatabase extends SS_Database {
}
}
$this->tableList = $this->fieldList = $this->indexList = null;
$this->tableList = $this->fieldList = $this->indexList = $this->fullTextEnabled = null;
}
/**