Ferreteria/v0.3/class/tKeyedRow
< Ferreteria | v0.3 | class
Jump to navigation
Jump to 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());
}
}