コード例 #1
0
 /**
  * @return InsertOrUpdateQuery
  **/
 public function fillQuery(InsertOrUpdateQuery $query, Prototyped $object)
 {
     if ($this->relationId || $this->generic) {
         // skip collections
         if ($this->relationId != MetaRelation::ONE_TO_ONE && !$this->generic) {
             return $query;
         }
         $value = $object->{$this->getter}();
         if ($this->type == 'binary') {
             $query->set($this->columnName, new DBBinary($value));
         } else {
             $query->lazySet($this->columnName, $value);
         }
     }
     return $query;
 }
コード例 #2
0
 /**
  * @return InsertOrUpdateQuery
  **/
 public function fillQuery(InsertOrUpdateQuery $query, Prototyped $object, Prototyped $old = null)
 {
     if ($this->relationId || $this->generic) {
         // skip collections
         if ($this->relationId != MetaRelation::ONE_TO_ONE && !$this->generic) {
             return $query;
         }
         $getter = $this->getter;
         if ($this->relationId && $this->strategyId == FetchStrategy::LAZY) {
             $getter = $getter . 'Id';
         }
         $value = $object->{$getter}();
         if ($old) {
             $oldValue = $old->{$getter}();
             if ($oldValue === null && $value === $oldValue) {
                 return $query;
             } elseif ($this->relationId && $this->strategyId == FetchStrategy::LAZY && $value === $oldValue) {
                 return $query;
             } elseif ($value instanceof Identifiable && $oldValue instanceof Identifiable && $value->getId() === $oldValue->getId()) {
                 return $query;
             } elseif (serialize($value) == serialize($oldValue)) {
                 return $query;
             }
         }
         if ($this->type == 'binary') {
             $query->set($this->columnName, new DBBinary($value));
         } else {
             $query->lazySet($this->columnName, $value);
         }
     }
     return $query;
 }