public static function getByID($avID) { $fav = new FileAttributeValue(); $fav->load($avID); if ($fav->getAttributeValueID() == $avID) { return $fav; } }
public function getAttributeValueObject($ak, $createIfNotFound = false) { $db = Loader::db(); $av = false; $v = array($this->getFileID(), $this->getFileVersionID(), $ak->getAttributeKeyID()); $avID = $db->GetOne("select avID from FileAttributeValues where fID = ? and fvID = ? and akID = ?", $v); if ($avID > 0) { $av = FileAttributeValue::getByID($avID); if (is_object($av)) { $av->setFile($this->getFile()); $av->setAttributeKey($ak); } } if ($createIfNotFound) { $cnt = 0; // Is this avID in use ? if (is_object($av)) { $cnt = $db->GetOne("select count(avID) from FileAttributeValues where avID = ?", $av->getAttributeValueID()); } if ((!is_object($av)) || ($cnt > 1)) { $av = $ak->addAttributeValue(); } } return $av; }