コード例 #1
0
 public static function RestoreByNameForClass($strName, $intClassId, $strVersion)
 {
     $objClassProperty = ClassProperty::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::ClassProperty()->QcodoClassId, $intClassId), QQ::Equal(QQN::ClassProperty()->Variable->Name, $strName)));
     if (!$objClassProperty) {
         $objConnectedClassVariable = ClassVariable::LoadByPartialNameForClass($strName, $intClassId);
         $objVariable = Variable::CreateNewForName($strName, $strVersion);
         $objClassProperty = new ClassProperty();
         $objClassProperty->QcodoClassId = $intClassId;
         $objClassProperty->VariableGroupId = 1;
         $objClassProperty->Variable = $objVariable;
         if ($objConnectedClassVariable) {
             $objClassProperty->ClassVariable = $objConnectedClassVariable;
             $objClassProperty->VariableGroupId = $objConnectedClassVariable->VariableGroupId;
         }
         $objClassProperty->Save();
     } else {
         if ($objClassProperty->Variable->LastVersion) {
             $objClassProperty->Variable->LastVersion = null;
             $objClassProperty->Variable->Save();
         }
         if ($objClassProperty->ClassVariable) {
             $objClassProperty->VariableGroupId = $objClassProperty->ClassVariable->VariableGroupId;
             $objClassProperty->Save();
         }
     }
     return $objClassProperty;
 }