mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed MSSQL date tweak to not accidentally generate default values for dates.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79311 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
add7d31d8b
commit
b536ecd610
@ -261,20 +261,22 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
if(DB::getConn() instanceof MSSQLDatabase) {
|
if(DB::getConn() instanceof MSSQLDatabase) {
|
||||||
$this->class = get_class($this);
|
$this->class = get_class($this);
|
||||||
foreach($record as $k => $v) {
|
foreach($record as $k => $v) {
|
||||||
// MSSQLDatabase::date() uses datetime for the data type for "Date" and "SSDatetime"
|
if($v) {
|
||||||
switch($this->db($k)) {
|
// MSSQLDatabase::date() uses datetime for the data type for "Date" and "SSDatetime"
|
||||||
case "Date":
|
switch($this->db($k)) {
|
||||||
$meridiem = substr($v, strlen($v) - 2, strlen($v));
|
case "Date":
|
||||||
$v = substr($v, 0, strlen($v) - 6);
|
$meridiem = substr($v, strlen($v) - 2, strlen($v));
|
||||||
$record[$k] = date('Y-m-d', strtotime($v . ' ' . $meridiem));
|
$v = substr($v, 0, strlen($v) - 6);
|
||||||
break;
|
$record[$k] = date('Y-m-d', strtotime($v . ' ' . $meridiem));
|
||||||
|
break;
|
||||||
|
|
||||||
case "Datetime":
|
case "Datetime":
|
||||||
case "SSDatetime":
|
case "SSDatetime":
|
||||||
$meridiem = substr($v, strlen($v) - 2, strlen($v));
|
$meridiem = substr($v, strlen($v) - 2, strlen($v));
|
||||||
$v = substr($v, 0, strlen($v) - 6);
|
$v = substr($v, 0, strlen($v) - 6);
|
||||||
$record[$k] = date('Y-m-d H:i:s', strtotime($v . ' ' . $meridiem));
|
$record[$k] = date('Y-m-d H:i:s', strtotime($v . ' ' . $meridiem));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user