mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 05:07:36 +02:00
code smoothing
This commit is contained in:
@@ -638,7 +638,7 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
|
|
||||||
} elseif (class_exists('DateTime', FALSE)) { // since PHP 5.2
|
} elseif (class_exists('DateTime', FALSE)) { // since PHP 5.2
|
||||||
$value = new DateTime($value);
|
$value = new DateTime($value);
|
||||||
return $value ? $value->format($format) : NULL;
|
return $value->format($format);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return date($format, strtotime($value));
|
return date($format, strtotime($value));
|
||||||
|
@@ -62,7 +62,7 @@ class DibiRow extends ArrayObject
|
|||||||
|
|
||||||
} elseif (class_exists('DateTime', FALSE)) { // since PHP 5.2
|
} elseif (class_exists('DateTime', FALSE)) { // since PHP 5.2
|
||||||
$time = new DateTime($time);
|
$time = new DateTime($time);
|
||||||
return $time ? $time->format($format) : NULL;
|
return $time->format($format);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return date($format, strtotime($time));
|
return date($format, strtotime($time));
|
||||||
|
@@ -417,27 +417,29 @@ final class DibiTranslator extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
// without modifier procession
|
// without modifier procession
|
||||||
if (is_string($value))
|
if (is_string($value)) {
|
||||||
return $this->driver->escape($value, dibi::TEXT);
|
return $this->driver->escape($value, dibi::TEXT);
|
||||||
|
|
||||||
if (is_int($value) || is_float($value))
|
} elseif (is_int($value) || is_float($value)) {
|
||||||
return rtrim(rtrim(number_format($value, 5, '.', ''), '0'), '.');
|
return rtrim(rtrim(number_format($value, 5, '.', ''), '0'), '.');
|
||||||
|
|
||||||
if (is_bool($value))
|
} elseif (is_bool($value)) {
|
||||||
return $this->driver->escape($value, dibi::BOOL);
|
return $this->driver->escape($value, dibi::BOOL);
|
||||||
|
|
||||||
if ($value === NULL)
|
} elseif ($value === NULL) {
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
|
|
||||||
if ($value instanceof IDibiVariable)
|
} elseif ($value instanceof IDibiVariable) {
|
||||||
return $value->toSql($this, NULL);
|
return $value->toSql($this, NULL);
|
||||||
|
|
||||||
if ($value instanceof DateTime)
|
} elseif ($value instanceof DateTime) {
|
||||||
return $this->driver->escape($value, dibi::DATETIME);
|
return $this->driver->escape($value, dibi::DATETIME);
|
||||||
|
|
||||||
|
} else {
|
||||||
$this->hasError = TRUE;
|
$this->hasError = TRUE;
|
||||||
return '**Unexpected ' . gettype($value) . '**';
|
return '**Unexpected ' . gettype($value) . '**';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user