Пример #1
0
 /**
  * Checks is attribute have this value?
  *
  * @param 		RM_Gpc_Attribute_Value		obValue
  * @return		bool
  **/
 public function isValue(RM_Gpc_Attribute_Value $obValue)
 {
     return !isNull(iterFirst($this->getValues()->filter('id = ?', $obValue->id())));
 }
Пример #2
0
 /**
  * Removes Attribute2Value relation
  *
  * @param 		RM_Gpc_Attribute_Object		obAttribute
  * @param 		RM_Gpc_Attribute_Value		obValue
  * @param 		RM_Gpc_Entity_Brick			obBrick
  * @return		bool
  **/
 public function removeValueFromAttribute(RM_Gpc_Attribute_Object $obAttribute, RM_Gpc_Attribute_Value $obValue, RM_Gpc_Entity_Brick $obBrick)
 {
     $binds = array($this->_fields['value2attr']['attribute_id'] => $obAttribute->id(), $this->_fields['value2attr']['value_id'] => $obValue->id(), $this->_fields['value2attr']['brick_id'] => $obBrick->id());
     $query = M('Db')->createQuery($this->_tables['value2attr'], 'delete');
     foreach ($binds as $k => $v) {
         $query->where($k . '= ?', $v);
     }
     $result = $query->execute();
     // удалить все связи вида Master2Slave данного атрибута с другими атрибутами этого же брика (Brick/Master/Slave/Value relation into master2slave)
     foreach ($obAttribute->getMasters($obBrick) as $obMaster) {
         $this->removeMasterFromSlave($obBrick, $obMaster, $obAttribute, $obValue);
     }
     foreach ($obAttribute->getSlaves($obBrick) as $obSlave) {
         $this->removeMasterFromSlave($obBrick, $obAttribute, $obSlave, $obValue);
     }
     return $result;
 }