You are here

function DB_storage::set in Flickr API 5

Modify an attriute value.

File

phpFlickr/PEAR/DB/storage.php, line 361

Class

DB_storage
Provides an object interface to a table row

Code

function set($property, $newvalue) {

  // only change if $property is known and object is not
  // read-only
  if ($this->_readonly) {
    return $this
      ->raiseError(null, DB_WARNING_READ_ONLY, null, null, null, null, true);
  }
  if (@isset($this->_properties[$property])) {
    if (empty($this->_validator)) {
      $valid = true;
    }
    else {
      $valid = @call_user_func($this->_validator, $this->_table, $property, $newvalue, $this->{$property}, $this);
    }
    if ($valid) {
      $this->{$property} = $newvalue;
      if (empty($this->_changes[$property])) {
        $this->_changes[$property] = 0;
      }
      else {
        $this->_changes[$property]++;
      }
    }
    else {
      return $this
        ->raiseError(null, DB_ERROR_INVALID, null, null, "invalid field: {$property}", null, true);
    }
    return true;
  }
  return $this
    ->raiseError(null, DB_ERROR_NOSUCHFIELD, null, null, "unknown field: {$property}", null, true);
}