Skip to content

Commit

Permalink
Add DateTime format support to PgSQLDriver, SQLBuilder cast method
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jun 15, 2016
1 parent 36686a9 commit 2feaa86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions SQLBuilder/Driver/PgSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function cast($value)
} else if ($value === false) {
return 0;
}
if ($value instanceof DateTime) {
return $value->format(DateTime::ATOM);
}
return $value;
}
}
Expand Down
5 changes: 4 additions & 1 deletion SQLBuilder/Driver/SQLiteDriver.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
namespace SQLBuilder\Driver;
use SQLBuilder\ArgumentArray;
use DateTime;
use Exception;
use RuntimeException;
use SQLBuilder\ArgumentArray;

/**
* Currently not supporting this SQLiteDriver
Expand All @@ -23,6 +23,9 @@ public function cast($value)
} else if ($value === false) {
return 0;
}
if ($value instanceof DateTime) {
return $value->format(DateTime::ATOM);
}
return $value;
}

Expand Down

0 comments on commit 2feaa86

Please sign in to comment.