예제 #1
0
 /**
  * 
  * @param CAttribute $oAttribute
  * @return boolean
  * @throws CApiManagerException
  */
 public function setAttribute(CAttribute $oAttribute)
 {
     $bResult = false;
     try {
         if ($oAttribute->validate()) {
             if (!$this->oStorage->setAttributes(array($oAttribute->EntityId), array($oAttribute))) {
                 throw new CApiManagerException(Errs::Main_UnknownError);
             }
         }
     } catch (CApiBaseException $oException) {
         $bResult = false;
         $this->setLastException($oException);
     }
     return $bResult;
 }
예제 #2
0
 /**
  * 
  * @param type $sType
  * @param type $aViewAttrs
  * @param type $iOffset
  * @param type $iLimit
  * @param type $aSearchAttrs
  * @param type $sOrderBy
  * @param type $iSortOrder
  * @param type $aIdsOrUUIDs
  * @return \AEntity
  */
 public function getEntities($sType, $aViewAttrs = array(), $iOffset = 0, $iLimit = 20, $aSearchAttrs = array(), $sOrderBy = '', $iSortOrder = \ESortOrder::ASC, $aIdsOrUUIDs = array())
 {
     $mResult = false;
     if ($aViewAttrs === null) {
         $aViewAttrs = array();
     } else {
         if (count($aViewAttrs) === 0) {
             $this->oConnection->Execute($this->oCommandCreator->getAttributesNamesByEntityType($sType));
             while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
                 $aViewAttrs[] = $oRow->name;
             }
             $this->oConnection->FreeResult();
         }
     }
     if ($this->oConnection->Execute($this->oCommandCreator->getEntities($sType, $aViewAttrs, $iOffset, $iLimit, $aSearchAttrs, $sOrderBy, $iSortOrder, $aIdsOrUUIDs))) {
         $oRow = null;
         $mResult = array();
         while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
             if (class_exists($sType)) {
                 $oEntity = call_user_func($sType . '::createInstance');
             } else {
                 $oEntity = new \AEntity($sType);
             }
             $oEntity->iId = (int) $oRow->entity_id;
             $oEntity->sUUID = $oRow->entity_uuid;
             $oEntity->sModuleName = $oRow->entity_module;
             foreach (get_object_vars($oRow) as $sKey => $mValue) {
                 if (strrpos($sKey, 'attr_', -5) !== false) {
                     $sAttrKey = substr($sKey, 5);
                     $oEntity->{$sAttrKey} = \CAttribute::createInstance($sAttrKey, $mValue, null, $oEntity->isEncryptedAttribute($sAttrKey), $oEntity->iId);
                 }
             }
             $mResult[] = $oEntity;
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $mResult;
 }
예제 #3
0
 /**
  * @param string $sAttribute
  * @param mixed $mValue
  * @return void
  */
 public function __set($sAttribute, $mValue)
 {
     if (!$mValue instanceof \CAttribute) {
         $mValue = \CAttribute::createInstance($sAttribute, $mValue, $this->getType($sAttribute), $this->isEncryptedAttribute($sAttribute), $this->iId);
     }
     if ($mValue->Encrypted) {
         $mValue->Encrypt();
     }
     $this->setAttribute($mValue);
 }