BUGFIX: Added default value to decimal field type.

ENHANCEMENT: Added MSSQL::allowPrimaryKeyEditing() method to access SET IDENTITY_INSERT method.
BUGFIX: Fix sort by RAND()
This commit is contained in:
Sam Minnee 2009-05-07 05:55:05 +00:00
parent 293b156cb7
commit dc080b0e28

View File

@ -705,7 +705,7 @@ class MSSQLDatabase extends Database {
if($asDbValue)
return Array('data_type'=>'decimal', 'numeric_precision'=>'9,2');
else return 'decimal(' . $precision . ') not null';
else return 'decimal(' . $precision . ') not null default 0';
}
/**
@ -893,6 +893,8 @@ class MSSQLDatabase extends Database {
public function sqlQueryToString(SQLQuery $sqlQuery) {
if (!$sqlQuery->from) return '';
if($sqlQuery->orderby && strtoupper(trim($sqlQuery->orderby)) == 'RAND()') $sqlQuery->orderby = "NEWID()";
//TODO: remove me when the limit function supposedly works
$sqlQuery->limit='';
@ -1026,6 +1028,16 @@ class MSSQLDatabase extends Database {
return $searchResults;
}
/**
* Allow auto-increment primary key editing on the given table.
* Some databases need to enable this specially.
* @param $table The name of the table to have PK editing allowed on
* @param $allow True to start, false to finish
*/
function allowPrimaryKeyEditing($table, $allow = true) {
$this->query("SET IDENTITY_INSERT \"$table\" " . ($allow ? "ON" : "OFF"));
}
}
/**