Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function persistProperty(IObject $object, IProperty $property, IQueryBuilder $builder)
 {
     if ($builder instanceof IUpdateBuilder) {
         $increment = $property->getDbValue() - $property->getPersistedDbValue();
         if ($increment !== 0) {
             $incrementExpression = $builder->getConnection()->quoteIdentifier($this->getColumnName()) . ' + (' . $increment . ')';
             $builder->set($this->getColumnName(), ':new' . $this->getColumnName())->bindExpression(':new' . $this->getColumnName(), $incrementExpression);
         }
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function persistProperty(IObject $object, IProperty $property, IQueryBuilder $builder)
 {
     $localeId = $property->getLocaleId();
     if ($localeId && !$this->hasLocale($localeId)) {
         return $this;
     }
     /**
      * @var IUpdateBuilder $builder
      */
     if ($builder instanceof IUpdateBuilder) {
         $increment = $property->getDbValue() - $property->getPersistedDbValue();
         if ($increment !== 0) {
             $incrementExpression = $builder->getConnection()->quoteIdentifier($this->getColumnName()) . ' + (' . $increment . ')';
             $builder->set($this->getColumnName($localeId), ':new' . $this->getColumnName($localeId))->bindExpression(':new' . $this->getColumnName($localeId), $incrementExpression);
         }
     } elseif ($builder instanceof IInsertBuilder) {
         $builder->set($this->getColumnName($localeId));
         $builder->bindValue(':' . $this->getColumnName($localeId), $this->calculateDBValue($object, $localeId), $this->getDataType());
     }
     return $this;
 }