Commit ef8365a080fb05367ceabf585d95f95d843a2af2

Authored by nbm
1 parent b469ac6c

Standardise on 'Id' ending and not 'ID'.

Add getByLookupSingle and getByLookup to find value instances from the
values they represent.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3747 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/metadata/valueinstance.inc.php
... ... @@ -43,14 +43,14 @@ class KTValueInstance extends KTEntity {
43 43  
44 44 var $_bUsePearError = true;
45 45  
46   - function getID() { return $this->iId; }
47   - function getFieldID() { return $this->iFieldID; }
48   - function getFieldValue() { return $this->iFieldValue; }
49   - function getBehaviourID() { return $this->iBehaviourID; }
50   - function setID($iId) { $this->iId = $iId; }
51   - function setFieldID($iFieldID) { $this->iFieldID = $iFieldID; }
52   - function setFieldValue($iFieldValue) { $this->iFieldValue = $iFieldValue; }
53   - function setBehaviourID($iBehaviourID) { $this->iBehaviourID = $iBehaviourID; }
  46 + function getId() { return $this->iId; }
  47 + function getFieldId() { return $this->iFieldId; }
  48 + function getFieldValueId() { return $this->iFieldValueId; }
  49 + function getBehaviourId() { return $this->iBehaviourId; }
  50 + function setId($iId) { $this->iId = $iId; }
  51 + function setFieldId($iFieldId) { $this->iFieldId = $iFieldId; }
  52 + function setFieldValueId($iFieldValue) { $this->iFieldValueId = $iFieldValueId; }
  53 + function setBehaviourId($iBehaviourId) { $this->iBehaviourId = $iBehaviourId; }
54 54  
55 55 function _table () {
56 56 return KTUtil::getTableName('field_value_instances');
... ... @@ -74,12 +74,20 @@ class KTValueInstance extends KTEntity {
74 74  
75 75 // STATIC
76 76 function &getByField($oField) {
77   - if (is_object($oField)) {
78   - $iFieldID = $oField->getID();
79   - } else {
80   - $iFieldID = $oField;
81   - }
82   - return KTEntityUtil::getBy('KTValueInstance', 'fieldid', $iFieldID);
  77 + $iFieldId = KTUtil::getId($oField);
  78 + return KTEntityUtil::getBy('KTValueInstance', 'fieldid', $iFieldId);
  79 + }
  80 +
  81 + function &getByLookupSingle($oLookup) {
  82 + $aOptions = array('noneok' => true);
  83 + $iLookupId = KTUtil::getId($oLookup);
  84 + return KTEntityUtil::getBy('KTValueInstance', 'field_value_id', $iLookupId, $aOptions);
  85 + }
  86 +
  87 + function &getByLookup($oLookup, $aOptions) {
  88 + $aOptions = array('multi' => true);
  89 + $iLookupId = KTUtil::getId($oLookup);
  90 + return KTEntityUtil::getBy('KTValueInstance', 'field_value_id', $iLookupId, $aOptions);
83 91 }
84 92 }
85 93  
... ...