MINOR: MSSQL stub function created for Postgres-specific functionality

This commit is contained in:
Geoff Munn 2011-01-12 02:05:32 +00:00
parent c104222019
commit 7ea6652e56

View File

@ -322,8 +322,8 @@ class MSSQLDatabase extends SS_Database {
* @param string $tableName Name of table with primary key column "ID"
* @return string Internal identifier for primary key
*/
function getPrimaryKey($tableName) {
$indexes = DB::query("EXEC sp_helpindex '$tableName';");
function getPrimaryKey($tableName){
$indexes=DB::query("EXEC sp_helpindex '$tableName';");
$indexName = '';
foreach($indexes as $index) {
if($index['index_keys'] == 'ID') {
@ -569,6 +569,7 @@ class MSSQLDatabase extends SS_Database {
and c.name = '$colName'")->value();
}
/**
* Get enum values from a constraint check clause.
* @param string $clause Check clause to parse values from
@ -581,6 +582,7 @@ class MSSQLDatabase extends SS_Database {
$bits = preg_split('/ *= */', $segment);
for($i = 1; $i < sizeof($bits); $i += 2) {
array_unshift($constraints, substr(rtrim($bits[$i], ')'), 1, -1));
}
}
return $constraints;
@ -637,6 +639,8 @@ class MSSQLDatabase extends SS_Database {
//NOTE: 'with nocheck' seems to solve a few problems I've been having for modifying existing tables.
$alterCol .= ";\n$prefix WITH NOCHECK ADD CONSTRAINT \"{$tableName}_{$colName}_check\" $matches[4]";
}
}
}
@ -744,7 +748,7 @@ class MSSQLDatabase extends SS_Database {
$clause = $this->getConstraintCheckClause($table, $field['column_name']);
if($clause) {
$constraints = $this->enumValuesFromCheckClause($clause);
$default = substr($field['column_default'], 2, -2);
$default=substr($field['column_default'], 2, -2);
$field['data_type'] = $this->enum(array(
'default' => $default,
'name' => $field['column_name'],
@ -778,6 +782,18 @@ class MSSQLDatabase extends SS_Database {
return $output;
}
/**
*
* This is a stub function. Postgres caches the fieldlist results.
*
* @param string $tableName
*
* @return boolean
*/
function clear_cached_fieldlist($tableName=false){
return true;
}
/**
* Create an index on a table.
* @param string $tableName The name of the table.
@ -863,7 +879,7 @@ class MSSQLDatabase extends SS_Database {
public function alterIndex($tableName, $indexName, $indexSpec) {
$indexSpec = trim($indexSpec);
if($indexSpec[0] != '(') {
list($indexType, $indexFields) = explode(' ', $indexSpec, 2);
list($indexType, $indexFields) = explode(' ',$indexSpec,2);
} else {
$indexFields = $indexSpec;
}
@ -1148,7 +1164,7 @@ class MSSQLDatabase extends SS_Database {
/**
* Returns the database-specific version of the random() function
*/
function random() {
function random(){
return 'RAND()';
}
@ -1251,9 +1267,10 @@ class MSSQLDatabase extends SS_Database {
* @param string $value String to escape
* @return string Escaped string
*/
function addslashes($value) {
$value = str_replace("'", "''", $value);
$value = str_replace("\0", "[NULL]", $value);
function addslashes($value){
$value=str_replace("'","''",$value);
$value=str_replace("\0","[NULL]",$value);
return $value;
}
@ -1692,7 +1709,6 @@ class MSSQLQuery extends SS_Query {
public function numRecords() {
if(!is_resource($this->handle)) return false;
if($this->mssql) {
return mssql_num_rows($this->handle);
} else {
@ -1706,6 +1722,7 @@ class MSSQLQuery extends SS_Query {
}
public function nextRecord() {
if(!is_resource($this->handle)) return false;
// Coalesce rather than replace common fields.