Skip to content
Browse files

BUGFIX Ensure DateTime objects are handled correctly

  • Loading branch information...
1 parent 30f0173 commit 05d24b0843968eab901282b66b44f0805dc7ca47 @halkyon halkyon committed
Showing with 6 additions and 0 deletions.
  1. +6 −0 code/MSSQLDatabase.php
View
6 code/MSSQLDatabase.php
@@ -1781,6 +1781,12 @@ public function nextRecord() {
}
} else {
if($data = sqlsrv_fetch_array($this->handle, SQLSRV_FETCH_ASSOC)) {
+
+ // special case for sqlsrv - date values are DateTime coming out of the sqlsrv drivers,
+ // so we convert to the usual Y-m-d H:i:s value!
+ foreach($data as $name => $value) {
+ if($value instanceof DateTime) $data[$name] = $value->format('Y-m-d H:i:s');
+ }
return $data;
} else {
// Free the handle if there are no more results - sqlsrv crashes if there are too many handles

0 comments on commit 05d24b0

Please sign in to comment.
Something went wrong with that request. Please try again.