Example #1
0
 /**
  * Sets the value of a field on this object.
  * @param Field $field The field to set.
  * @param string $value Raw value of the field.
  * @throws BadMethodCallException If the object is already constructed.
  */
 public function setField(Field $field, $value)
 {
     if ($this->state == self::INTERNAL_STATE_FINAL && $field->getType() != Field::TYPE_PRIMARY_KEY) {
         // Primary key can be changed for insert queries to set the id to
         // something else than 0
         throw new BadMethodCallException("Already constructed");
     }
     $this->state = self::INTERNAL_STATE_SETTING;
     $fieldName = $field->getName();
     $this->{$fieldName} = $field->deserializeValue($value);
 }