Skip to content

Commit

Permalink
Update ActiveRecord.php
Browse files Browse the repository at this point in the history
  • Loading branch information
viames committed Jan 5, 2023
1 parent 6c8a81a commit 9be3a34
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ private function prepareData(array $properties) {

// should be DateTime, maybe null
case 'DateTime':
if (is_a($this->$prop, 'DateTime')) {
$dt = clone $this->$prop;
if (is_a($this->__get($prop), 'DateTime')) {
$dt = clone $this->__get($prop);
$dt->setTimezone(Application::getTimeZone());
$ret = $dt->format('Y-m-d H:i:s');
} else if (static::isNullable($field)) {
Expand All @@ -472,25 +472,25 @@ private function prepareData(array $properties) {

// join array strings in CSV format
case 'csv':
$ret = implode(',', array_filter((array)$this->$prop));
$ret = implode(',', array_filter((array)$this->__get($prop)));
break;

case 'float':
if (is_null($this->$prop) and static::isNullable($field)) {
if (is_null($this->__get($prop)) and static::isNullable($field)) {
$ret = NULL;
} else {
$curr = setlocale(LC_NUMERIC, 0);
setlocale(LC_NUMERIC, 'en_US');
$ret = (string)$this->$prop;
$ret = (string)$this->__get($prop);
setlocale(LC_NUMERIC, $curr);
}
break;

case 'json':
if (is_null($this->$prop) and static::isNullable($field)) {
if (is_null($this->__get($prop)) and static::isNullable($field)) {
$ret = NULL;
} else {
$ret = json_encode($this->$prop);
$ret = json_encode($this->__get($prop));
}
break;

Expand All @@ -499,7 +499,7 @@ private function prepareData(array $properties) {
if ((is_null($this->__get($prop)) or (''==$this->__get($prop) and !static::isEmptiable($field))) and static::isNullable($field)) {
$ret = NULL;
} else {
$ret = $this->$prop;
$ret = $this->__get($prop);
}
break;

Expand Down

0 comments on commit 9be3a34

Please sign in to comment.