From e4d992ae50e45c9a356d3a83e8ed778fabfda0a1 Mon Sep 17 00:00:00 2001 From: Michael Calcinai Date: Wed, 18 May 2016 12:41:32 +0200 Subject: [PATCH 1/2] Updated the aliases not to be an array, as there's no way you'd be able to identify it anyway. --- src/Wave/DB/Model.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Wave/DB/Model.php b/src/Wave/DB/Model.php index f2eac78..d50a482 100644 --- a/src/Wave/DB/Model.php +++ b/src/Wave/DB/Model.php @@ -16,7 +16,7 @@ class Model implements \JsonSerializable { /** @var string */ protected static $_database; /** @var string */ - protected static $_schema_names = []; + protected static $_schema_name = []; /** @var string */ protected static $_table_name; @@ -234,7 +234,7 @@ public function _equals(Model $object) { * @param $resolved_class */ public function addJoinedObject(Model &$object, $alias, $resolved_class) { - $this->_joined_aliases[$resolved_class][] = $alias; + $this->_joined_aliases[$resolved_class] = $alias; if(!isset($this->_joined_objects[$alias])) $this->_joined_objects[$alias] = array(); @@ -281,11 +281,11 @@ public static function _getTableName() { public static function _getSchemaName() { $namespace = static::_getDatabaseNamespace(); - if(!isset(static::$_schema_names[$namespace])) { - static::$_schema_names[$namespace] = DB::get($namespace)->getSchema(); + if(!isset(static::$_schema_name[$namespace])) { + static::$_schema_name[$namespace] = DB::get($namespace)->getSchema(); } - return static::$_schema_names[$namespace]; + return static::$_schema_name[$namespace]; } /** @@ -370,9 +370,12 @@ public function _getJoinedObjects() { public function _getJoinedObjectsForClass($class) { $objects = array(); if(isset($this->_joined_aliases[$class])) { - foreach($this->_joined_aliases[$class] as $alias) { - $objects = array_merge($objects, $this->_joined_objects[$alias]); - } + + return $this->_joined_objects[$this->_joined_aliases[$class]]; +// There really should only be one in here.. +// foreach($this->_joined_aliases[$class] as $alias) { +// $objects = array_merge($objects, $this->_joined_objects[$alias]); +// } } return $objects; } From 53e3a54c608682ef8e36aecb48ad0eef760578e5 Mon Sep 17 00:00:00 2001 From: Michael Calcinai Date: Wed, 18 May 2016 17:38:28 +0200 Subject: [PATCH 2/2] ORM tz --- src/Wave/DB/Driver/AbstractDriver.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Wave/DB/Driver/AbstractDriver.php b/src/Wave/DB/Driver/AbstractDriver.php index 71f5098..be74faa 100755 --- a/src/Wave/DB/Driver/AbstractDriver.php +++ b/src/Wave/DB/Driver/AbstractDriver.php @@ -13,6 +13,9 @@ public static function valueToSQL($value) { case is_bool($value): return $value ? 1 : 0; case $value instanceof DateTime: + if($value->getTimezone()->getName() !== date_default_timezone_get()){ + $value->setTimezone(new \DateTimeZone(date_default_timezone_get())); + } return $value->format('Y-m-d H:i:s'); default: @@ -43,8 +46,9 @@ public static function valueFromSQL($value, array $field_data) { case Column::TYPE_DATE: case Column::TYPE_TIMESTAMP: - if($value == 'CURRENT_TIMESTAMP') + if($value == 'CURRENT_TIMESTAMP'){ $value = 'now'; + } return new DateTime($value); default: