1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-07 14:46:50 +02:00

OdbcDriver: added option 'microseconds'

This commit is contained in:
David Grudl
2018-08-09 22:51:35 +02:00
parent c8dfb1f863
commit 2870fb9b31

View File

@@ -21,6 +21,7 @@ use Dibi;
* - password (or pass) * - password (or pass)
* - persistent (bool) => try to find a persistent link? * - persistent (bool) => try to find a persistent link?
* - resource (resource) => existing connection resource * - resource (resource) => existing connection resource
* - microseconds (bool) => use microseconds in datetime format?
*/ */
class OdbcDriver implements Dibi\Driver class OdbcDriver implements Dibi\Driver
{ {
@@ -32,6 +33,9 @@ class OdbcDriver implements Dibi\Driver
/** @var int|null Affected rows */ /** @var int|null Affected rows */
private $affectedRows; private $affectedRows;
/** @var bool */
private $microseconds = true;
/** /**
* @throws Dibi\NotSupportedException * @throws Dibi\NotSupportedException
@@ -62,6 +66,10 @@ class OdbcDriver implements Dibi\Driver
if (!is_resource($this->connection)) { if (!is_resource($this->connection)) {
throw new Dibi\DriverException(odbc_errormsg() . ' ' . odbc_error()); throw new Dibi\DriverException(odbc_errormsg() . ' ' . odbc_error());
} }
if (isset($config['microseconds'])) {
$this->microseconds = (bool) $config['microseconds'];
}
} }
@@ -238,7 +246,7 @@ class OdbcDriver implements Dibi\Driver
if (!$value instanceof \DateTimeInterface) { if (!$value instanceof \DateTimeInterface) {
$value = new Dibi\DateTime($value); $value = new Dibi\DateTime($value);
} }
return $value->format('#m/d/Y H:i:s.u#'); return $value->format($this->microseconds ? '#m/d/Y H:i:s.u#' : '#m/d/Y H:i:s#');
} }