mirror of
https://github.com/dg/dibi.git
synced 2025-08-11 16:44:30 +02:00
uses only DateTimeInterface & Throwable
This commit is contained in:
@@ -266,7 +266,7 @@ FROM %SQL', $this->sql, '
|
|||||||
%ex', $this->sorting ? ['ORDER BY %by', $this->sorting] : NULL, '
|
%ex', $this->sorting ? ['ORDER BY %by', $this->sorting] : NULL, '
|
||||||
%ofs %lmt', $this->offset, $this->limit
|
%ofs %lmt', $this->offset, $this->limit
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
trigger_error($e->getMessage(), E_USER_ERROR);
|
trigger_error($e->getMessage(), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -292,12 +292,12 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d'");
|
return $value->format("'Y-m-d'");
|
||||||
@@ -305,12 +305,12 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d H:i:s.u'");
|
return $value->format("'Y-m-d H:i:s.u'");
|
||||||
|
@@ -242,12 +242,12 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d'");
|
return $value->format("'Y-m-d'");
|
||||||
@@ -255,12 +255,12 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d H:i:s.u'");
|
return $value->format("'Y-m-d H:i:s.u'");
|
||||||
|
@@ -334,12 +334,12 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d'");
|
return $value->format("'Y-m-d'");
|
||||||
@@ -347,12 +347,12 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d H:i:s.u'");
|
return $value->format("'Y-m-d H:i:s.u'");
|
||||||
|
@@ -266,12 +266,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("#m/d/Y#");
|
return $value->format("#m/d/Y#");
|
||||||
@@ -279,12 +279,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$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("#m/d/Y H:i:s.u#");
|
||||||
|
@@ -292,12 +292,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $this->fmtDate
|
return $this->fmtDate
|
||||||
@@ -307,12 +307,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $this->fmtDateTime
|
return $this->fmtDateTime
|
||||||
|
@@ -326,12 +326,12 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format($this->driverName === 'odbc' ? '#m/d/Y#' : "'Y-m-d'");
|
return $value->format($this->driverName === 'odbc' ? '#m/d/Y#' : "'Y-m-d'");
|
||||||
@@ -339,12 +339,12 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format($this->driverName === 'odbc' ? "#m/d/Y H:i:s.u#" : "'Y-m-d H:i:s.u'");
|
return $value->format($this->driverName === 'odbc' ? "#m/d/Y H:i:s.u#" : "'Y-m-d H:i:s.u'");
|
||||||
|
@@ -340,12 +340,12 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d'");
|
return $value->format("'Y-m-d'");
|
||||||
@@ -353,12 +353,12 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d H:i:s.u'");
|
return $value->format("'Y-m-d H:i:s.u'");
|
||||||
|
@@ -286,12 +286,12 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format($this->fmtDate);
|
return $value->format($this->fmtDate);
|
||||||
@@ -299,12 +299,12 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format($this->fmtDateTime);
|
return $value->format($this->fmtDateTime);
|
||||||
|
@@ -264,12 +264,12 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d'");
|
return $value->format("'Y-m-d'");
|
||||||
@@ -277,12 +277,12 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTimeInterface) {
|
||||||
$value = new Dibi\DateTime($value);
|
$value = new Dibi\DateTime($value);
|
||||||
}
|
}
|
||||||
return $value->format("'Y-m-d H:i:s.u'");
|
return $value->format("'Y-m-d H:i:s.u'");
|
||||||
|
@@ -448,7 +448,7 @@ class Fluent implements IDataSource
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this->connection->translate($this->_export());
|
return $this->connection->translate($this->_export());
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
trigger_error($e->getMessage(), E_USER_ERROR);
|
trigger_error($e->getMessage(), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -316,7 +316,7 @@ final class Translator
|
|||||||
if ($value !== NULL && !is_scalar($value)) { // array is already processed
|
if ($value !== NULL && !is_scalar($value)) { // array is already processed
|
||||||
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
|
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
|
||||||
$modifier = 'SQL';
|
$modifier = 'SQL';
|
||||||
} elseif (($value instanceof \DateTime || $value instanceof \DateTimeInterface) && ($modifier === 'd' || $modifier === 't')) {
|
} elseif ($value instanceof \DateTimeInterface && ($modifier === 'd' || $modifier === 't')) {
|
||||||
// continue
|
// continue
|
||||||
} else {
|
} else {
|
||||||
$type = is_object($value) ? get_class($value) : gettype($value);
|
$type = is_object($value) ? get_class($value) : gettype($value);
|
||||||
@@ -439,7 +439,7 @@ final class Translator
|
|||||||
} elseif ($value === NULL) {
|
} elseif ($value === NULL) {
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
|
|
||||||
} elseif ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
|
} elseif ($value instanceof \DateTimeInterface) {
|
||||||
return $this->driver->escapeDateTime($value);
|
return $this->driver->escapeDateTime($value);
|
||||||
|
|
||||||
} elseif ($value instanceof Literal) {
|
} elseif ($value instanceof Literal) {
|
||||||
|
@@ -121,13 +121,13 @@ interface Driver
|
|||||||
function escapeBool($value);
|
function escapeBool($value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function escapeDate($value);
|
function escapeDate($value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|\DateTimeInterface|string|int
|
* @param \DateTimeInterface|string|int
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function escapeDateTime($value);
|
function escapeDateTime($value);
|
||||||
|
Reference in New Issue
Block a user