Ferreteria/v3/class/tKeyedRow

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Ferreteria‎ | v3‎ | class
Jump to: navigation, search
trait tKeyedRow {

    protected function GetKeyName() {
	$tbl = $this->GetSourceObject();
	if (method_exists($tbl,'GetKeyName')) {
	    $sKey = $tbl->GetKeyName();
	} else {
	    $sKey = NULL;
	}
	return $sKey;
    }
    public function GetKeyField() {
	$sKey = $this->GetKeyName();
	$oField = $this->GetExistingField($sKey);
	return $oField;
    }
    public function GetKeyValue() {
	$sKey = $this->GetKeyName();
	if (is_null($sKey)) {
	    throw new exception('Ferreteria error: Could not retrieve key value because no key name is available.');
	} else {
	    $v = $this->GetValueNz($sKey);
	    return $v;
	}
    }
    public function SetKeyValue($id) {
	$sKey = $this->GetSourceObject()->GetKeyName();
	$this->SetValue($sKey,$id);
    }
    public function IsNew() {
	return is_null($this->GetKeyValue());
    }
}