mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
DibiRow: asBool(), asDate() and asTimestamp() deprecated
This commit is contained in:
@@ -43,11 +43,13 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
public function asDateTime($key, $format = NULL)
|
public function asDateTime($key, $format = NULL)
|
||||||
{
|
{
|
||||||
$time = $this[$key];
|
$time = $this[$key];
|
||||||
if ((int) $time === 0) { // '', NULL, FALSE, '0000-00-00', ...
|
if (!$time instanceof DibiDateTime) {
|
||||||
return NULL;
|
if ((int) $time === 0) { // '', NULL, FALSE, '0000-00-00', ...
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
$time = new DibiDateTime(is_numeric($time) ? date('Y-m-d H:i:s', $time) : $time);
|
||||||
}
|
}
|
||||||
$dt = new DibiDateTime(is_numeric($time) ? date('Y-m-d H:i:s', $time) : $time);
|
return $format === NULL ? $time : $time->format($format);
|
||||||
return $format === NULL ? $dt : $dt->format($format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,6 +61,7 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
*/
|
*/
|
||||||
public function asTimestamp($key)
|
public function asTimestamp($key)
|
||||||
{
|
{
|
||||||
|
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
|
||||||
$time = $this[$key];
|
$time = $this[$key];
|
||||||
return (int) $time === 0 // '', NULL, FALSE, '0000-00-00', ...
|
return (int) $time === 0 // '', NULL, FALSE, '0000-00-00', ...
|
||||||
? NULL
|
? NULL
|
||||||
@@ -74,13 +77,8 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
*/
|
*/
|
||||||
public function asBool($key)
|
public function asBool($key)
|
||||||
{
|
{
|
||||||
$value = $this[$key];
|
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
|
||||||
if ($value === NULL || $value === FALSE) {
|
return $this[$key];
|
||||||
return $value;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return ((bool) $value) && $value !== 'f' && $value !== 'F';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -88,6 +86,7 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public function asDate($key, $format = NULL)
|
public function asDate($key, $format = NULL)
|
||||||
{
|
{
|
||||||
|
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
|
||||||
if ($format === NULL) {
|
if ($format === NULL) {
|
||||||
return $this->asTimestamp($key);
|
return $this->asTimestamp($key);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user