Ferreteria/v0.3/class/tKeyedRow: Difference between revisions
< Ferreteria | v0.3 | class
Jump to navigation
Jump to search
(Created page with "{{page/code/class|ferreteria}} <source lang=php> trait tKeyedRow { protected function GetKeyName() { $tbl = $this->GetSourceObject(); if (method_exists($tbl,'GetKeyName...") |
m (3 revisions imported: moving this project here) |
(2 intermediate revisions by one other user not shown) | |
(No difference)
|
Latest revision as of 16:43, 22 May 2022
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());
}
}