1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +02:00

DibiRow: null time checking consistent with DibiResult

This commit is contained in:
David Grudl
2013-12-12 16:23:19 +01:00
parent 7318658017
commit 367b115ad2

View File

@@ -43,7 +43,7 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
{ {
$time = $this[$key]; $time = $this[$key];
if (!$time instanceof DibiDateTime) { if (!$time instanceof DibiDateTime) {
if ((int) $time === 0) { // '', NULL, FALSE, '0000-00-00', ... if ((int) $time === 0 && substr((string) $time, 0, 3) !== '00:') { // '', NULL, FALSE, '0000-00-00', ...
return NULL; return NULL;
} }
$time = new DibiDateTime($time); $time = new DibiDateTime($time);
@@ -60,11 +60,7 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
public function asTimestamp($key) public function asTimestamp($key)
{ {
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING); trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
$time = $this[$key]; return $this->asDateTime($key, 'U');
if ((int) $time !== 0) { // '', NULL, FALSE, '0000-00-00', ...
$time = new DibiDateTime($time);
return $time->getTimestamp();
}
} }