public function setField(string $field, $value)
    {
        if (isset($this->_record[$field]) && $this->_record[$field] === $value)
            return;

        $db = $this->getDB();
        $dao = $db->getDAO(static::class);
        $columns = $dao->getColumns();
        if (!isset($columns[$field]))
            throw new InvalidValueException("Field $field does not exist!");

        $pkey = $dao->getPrimaryKey();
        $coldef = $columns[$field];
        if (static::validate($coldef, $value))
        {
            $this->_record[$field] = $value;
            $this->_changed[$field] = true;

            if (isset($pkey[$field]))
                $this->_id[$field] = $value;

            // Synchronize value of local properties
            if (property_exists($this, $field))
                $this->$field = $value;
        }

        return $this;
    }
public function setField(string $field, $value)
    {
        if (isset($this->_record[$field]) && $this->_record[$field] === $value)
            return;

        $db = $this->getDB();
        $dao = $db->getDAO(static::class);
        $columns = $dao->getColumns();
        if (!isset($columns[$field]))
            throw new InvalidValueException("Field $field does not exist!");

        $pkey = $dao->getPrimaryKey();
        $coldef = $columns[$field];
        if (static::validate($coldef, $value))
        {
            $this->_record[$field] = $value;
            $this->_changed[$field] = true;

            if (isset($pkey[$field]))
                $this->_id[$field] = $value;

            // Synchronize value of local properties
            if (property_exists($this, $field))
                $this->$field = $value;
        }

        return $this;
    }
public function setField ( string $ field , $ value ) { if ( isset ( $ this -> _record [ $ field ] ) && $ this -> _record [ $ field ] === $ value ) return ; $ db = $ this -> getDB ( ) ; $ dao = $ db -> getDAO ( static :: class ) ; $ columns = $ dao -> getColumns ( ) ; if ( ! isset ( $ columns [ $ field ] ) ) throw new InvalidValueException ( "Field $field does not exist!" ) ; $ pkey = $ dao -> getPrimaryKey ( ) ; $ coldef = $ columns [ $ field ] ; if ( static :: validate ( $ coldef , $ value ) ) { $ this -> _record [ $ field ] = $ value ; $ this -> _changed [ $ field ] = true ; if ( isset ( $ pkey [ $ field ] ) ) $ this -> _id [ $ field ] = $ value ; // Synchronize value of local properties if ( property_exists ( $ this , $ field ) ) $ this -> $ field = $ value ; } return $ this ; }
Set a field to a new value. The value will be validated first by
calling validate.

@param string $field The field to retrieve
@param mixed $value The value to set it to.
@return Wedeto\DB\DAO Provides fluent interface.
Set a field to a new value . The value will be validated first by calling validate .