示例#1
0
 /**
  * {@inheritdoc}
  *
  * Must track field updates. In addition Records will not allow to set unknown field.
  *
  * @throws RecordException
  */
 public function setField($name, $value, $filter = true)
 {
     if (!array_key_exists($name, $this->fields)) {
         throw new RecordException("Undefined field '{$name}' in '" . static::class . "'.");
     }
     $original = isset($this->fields[$name]) ? $this->fields[$name] : null;
     if ($value === null && in_array($name, $this->ormSchema[ORM::M_NULLABLE])) {
         //We must bypass setters and accessors when null value assigned to nullable column
         $this->fields[$name] = null;
     } else {
         parent::setField($name, $value, $filter);
     }
     if (!array_key_exists($name, $this->updates)) {
         $this->updates[$name] = $original instanceof AccessorInterface ? $original->serializeData() : $original;
     }
 }
 /**
  * {@inheritdoc}
  *
  * Must track field updates.
  */
 public function setField($name, $value, $filter = true)
 {
     if (!array_key_exists($name, $this->fields)) {
         throw new FieldException("Undefined field '{$name}' in '" . static::class . "'.");
     }
     $original = isset($this->fields[$name]) ? $this->fields[$name] : null;
     parent::setField($name, $value, $filter);
     if (!array_key_exists($name, $this->updates)) {
         $this->updates[$name] = $original instanceof AccessorInterface ? $original->serializeData() : $original;
     }
 }