mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
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:
parent
5667388908
commit
d09acc0cbe
@ -53,7 +53,15 @@ class MSSQLDatabase extends SS_Database {
|
||||
*/
|
||||
public static $noiseWords = array("about", "1", "after", "2", "all", "also", "3", "an", "4", "and", "5", "another", "6", "any", "7", "are", "8", "as", "9", "at", "0", "be", "$", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could", "did", "do", "does", "each", "else", "for", "from", "get", "got", "has", "had", "he", "have", "her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "its", "just", "like", "make", "many", "me", "might", "more", "most", "much", "must", "my", "never", "no", "now", "of", "on", "only", "or", "other", "our", "out", "over", "re", "said", "same", "see", "should", "since", "so", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", "well", "were", "what", "when", "where", "which", "while", "who", "will", "with", "would", "you", "your", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
|
||||
|
||||
protected $supportsTransactions=false;
|
||||
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.
|
||||
@ -117,13 +125,16 @@ class MSSQLDatabase extends SS_Database {
|
||||
* @return boolean
|
||||
*/
|
||||
public function fullTextEnabled() {
|
||||
$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;
|
||||
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();
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user