mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
BUGFIX Removed MySQL specific stuff that was copied across on MSSQLDatabase
This commit is contained in:
parent
1964ac5907
commit
874f28aa71
@ -164,12 +164,12 @@ class MSSQLDatabase extends Database {
|
||||
|
||||
return $primary_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* OBSOLETE: Get the ID for the next new record for the table.
|
||||
*
|
||||
* @var string $table The name od the table.
|
||||
*
|
||||
* TODO: remove this? It's a MySQL legacy thing....
|
||||
* @return int
|
||||
*/
|
||||
public function getNextID($table) {
|
||||
@ -210,7 +210,7 @@ class MSSQLDatabase extends Database {
|
||||
*/
|
||||
public function selectDatabase($dbname) {
|
||||
$this->database = $dbname;
|
||||
if($this->databaseExists($this->database)) mysql_select_db($this->database, $this->dbConn);
|
||||
if($this->databaseExists($this->database)) mssql_select_db($this->database, $this->dbConn);
|
||||
$this->tableList = $this->fieldList = $this->indexList = null;
|
||||
}
|
||||
|
||||
@ -219,7 +219,13 @@ class MSSQLDatabase extends Database {
|
||||
*/
|
||||
public function databaseExists($name) {
|
||||
$SQL_name = Convert::raw2sql($name);
|
||||
return $this->query("SHOW DATABASES LIKE '$SQL_name'")->value() ? true : false;
|
||||
|
||||
$listDBs = $this->query('SELECT NAME FROM sys.sysdatabases');
|
||||
foreach($listDBs as $listedDB) {
|
||||
if($listedDB['NAME'] == $name) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable($tableName, $fields = null, $indexes = null) {
|
||||
@ -656,8 +662,7 @@ class MSSQLDatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a date type-formatted string
|
||||
* For MySQL, we simply return the word 'date', no other parameters are necessary
|
||||
* Return a date type-formatted string.
|
||||
*
|
||||
* @params array $values Contains a tokenised list of info about this data type
|
||||
* @return string
|
||||
@ -698,13 +703,12 @@ class MSSQLDatabase extends Database {
|
||||
//Enums are a bit different. We'll be creating a varchar(255) with a constraint of all the usual enum options.
|
||||
//NOTE: In this one instance, we are including the table name in the values array
|
||||
|
||||
return "varchar(255) not null default '" . $values['default'] . "' check (\"" . $values['name'] . "\" in ('" . implode('\', \'', $values['enums']) . "'))";
|
||||
return "varchar(255) not null default \"" . $values['default'] . "\" check(\"" . $values['name'] . "\" in ('" . implode('\', \'', $values['enums']) . "'))";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a float type-formatted string
|
||||
* For MySQL, we simply return the word 'date', no other parameters are necessary
|
||||
* Return a float type-formatted string.
|
||||
*
|
||||
* @params array $values Contains a tokenised list of info about this data type
|
||||
* @return string
|
||||
@ -757,8 +761,7 @@ class MSSQLDatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a time type-formatted string
|
||||
* For MySQL, we simply return the word 'time', no other parameters are necessary
|
||||
* Return a time type-formatted string.
|
||||
*
|
||||
* @params array $values Contains a tokenised list of info about this data type
|
||||
* @return string
|
||||
@ -780,8 +783,9 @@ class MSSQLDatabase extends Database {
|
||||
return 'varchar(' . $values['precision'] . ') null';
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a 4 digit numeric type. MySQL has a proprietary 'Year' type.
|
||||
/**
|
||||
* Return a 4 digit numeric type.
|
||||
* @return string
|
||||
*/
|
||||
public function year($values, $asDbValue=false){
|
||||
if($asDbValue)
|
||||
@ -797,7 +801,7 @@ class MSSQLDatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a fulltext search datatype for MySQL
|
||||
* Create a fulltext search datatype for MSSQL.
|
||||
*
|
||||
* @param array $spec
|
||||
*/
|
||||
@ -869,9 +873,7 @@ class MSSQLDatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a SQLQuery object into a SQL statement
|
||||
* @todo There is a lot of duplication between this and MySQLDatabase::sqlQueryToString(). Perhaps they could both call a common
|
||||
* helper function in Database?
|
||||
* Convert a SQLQuery object into a SQL statement.
|
||||
*/
|
||||
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
||||
if (!$sqlQuery->from) return '';
|
||||
@ -1012,19 +1014,19 @@ class MSSQLDatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* A result-set from a MySQL database.
|
||||
* A result-set from a MSSQL database.
|
||||
* @package sapphire
|
||||
* @subpackage model
|
||||
*/
|
||||
class MSSQLQuery extends Query {
|
||||
/**
|
||||
* The MySQLDatabase object that created this result set.
|
||||
* @var MySQLDatabase
|
||||
* The MSSQLDatabase object that created this result set.
|
||||
* @var MSSQLDatabase
|
||||
*/
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* The internal MySQL handle that points to the result set.
|
||||
* The internal MSSQL handle that points to the result set.
|
||||
* @var resource
|
||||
*/
|
||||
private $handle;
|
||||
@ -1032,7 +1034,7 @@ class MSSQLQuery extends Query {
|
||||
/**
|
||||
* Hook the result-set given into a Query class, suitable for use by sapphire.
|
||||
* @param database The database object that created this query.
|
||||
* @param handle the internal mysql handle that is points to the resultset.
|
||||
* @param handle the internal mssql handle that is points to the resultset.
|
||||
*/
|
||||
public function __construct(MSSQLDatabase $database, $handle) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user