mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 06:05:53 +00:00
BUGFIX: Fixed field renaming in MSSQLDatabase.
ENHANCEMENT: Added MSSQLDatabase::fullTextSearchSQL() for generating full-text queries in an abstract fashion.
This commit is contained in:
parent
dc080b0e28
commit
3fbf62c4cd
@ -446,7 +446,7 @@ class MSSQLDatabase extends Database {
|
|||||||
public function renameField($tableName, $oldName, $newName) {
|
public function renameField($tableName, $oldName, $newName) {
|
||||||
$fieldList = $this->fieldList($tableName);
|
$fieldList = $this->fieldList($tableName);
|
||||||
if(array_key_exists($oldName, $fieldList)) {
|
if(array_key_exists($oldName, $fieldList)) {
|
||||||
$this->query("ALTER TABLE \"$tableName\" RENAME COLUMN \"$oldName\" TO \"$newName\"");
|
$this->query("EXEC sp_rename @objname = '$tableName.$oldName', @newname = '$newName', @objtype = 'COLUMN'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1038,6 +1038,20 @@ class MSSQLDatabase extends Database {
|
|||||||
$this->query("SET IDENTITY_INSERT \"$table\" " . ($allow ? "ON" : "OFF"));
|
$this->query("SET IDENTITY_INSERT \"$table\" " . ($allow ? "ON" : "OFF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a SQL fragment for querying a fulltext search index
|
||||||
|
* @param $fields array The list of field names to search on
|
||||||
|
* @param $keywords string The search query
|
||||||
|
* @param $booleanSearch A MySQL-specific flag to switch to boolean search
|
||||||
|
*/
|
||||||
|
function fullTextSearchSQL($fields, $keywords, $booleanSearch = false) {
|
||||||
|
$fieldNames = '"' . implode('", "', $fields) . '"';
|
||||||
|
|
||||||
|
$SQL_keywords = Convert::raw2sql($keywords);
|
||||||
|
|
||||||
|
return "FREETEXT (($fieldNames), '$SQL_keywords')";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user