Esempio n. 1
0
 /**
  * Instantiate an array of VariableGroups from a Database Result
  * @param DatabaseResultBase $objDbResult
  * @return VariableGroup[]
  */
 public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null)
 {
     $objToReturn = array();
     // If blank resultset, then return empty array
     if (!$objDbResult) {
         return $objToReturn;
     }
     // Load up the return array with each row
     if ($strExpandAsArrayNodes) {
         $objLastRowItem = null;
         while ($objDbRow = $objDbResult->GetNextRow()) {
             $objItem = VariableGroup::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem);
             if ($objItem) {
                 array_push($objToReturn, $objItem);
                 $objLastRowItem = $objItem;
             }
         }
     } else {
         while ($objDbRow = $objDbResult->GetNextRow()) {
             array_push($objToReturn, VariableGroup::InstantiateDbRow($objDbRow));
         }
     }
     return $objToReturn;
 }
Esempio n. 2
0
 /**
  * Instantiate a ClassVariable from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this ClassVariable::InstantiateDbRow in order to perform
  * early binding on referenced objects.
  * @param DatabaseRowBase $objDbRow
  * @param string $strAliasPrefix
  * @return ClassVariable
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null)
 {
     // If blank row, return null
     if (!$objDbRow) {
         return null;
     }
     // See if we're doing an array expansion on the previous item
     if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intId == $objDbRow->GetColumn($strAliasPrefix . 'id', 'Integer')) {
         // We are.  Now, prepare to check for ExpandAsArray clauses
         $blnExpandedViaArray = false;
         if (!$strAliasPrefix) {
             $strAliasPrefix = 'class_variable__';
         }
         if (array_key_exists($strAliasPrefix . 'classproperty__id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'classproperty__id'))) {
             if ($intPreviousChildItemCount = count($objPreviousItem->_objClassPropertyArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objClassPropertyArray[$intPreviousChildItemCount - 1];
                 $objChildItem = ClassProperty::InstantiateDbRow($objDbRow, $strAliasPrefix . 'classproperty__', $strExpandAsArrayNodes, $objPreviousChildItem);
                 if ($objChildItem) {
                     array_push($objPreviousItem->_objClassPropertyArray, $objChildItem);
                 }
             } else {
                 array_push($objPreviousItem->_objClassPropertyArray, ClassProperty::InstantiateDbRow($objDbRow, $strAliasPrefix . 'classproperty__', $strExpandAsArrayNodes));
             }
             $blnExpandedViaArray = true;
         }
         // Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
         if ($blnExpandedViaArray) {
             return false;
         } else {
             if ($strAliasPrefix == 'class_variable__') {
                 $strAliasPrefix = null;
             }
         }
     }
     // Create a new instance of the ClassVariable object
     $objToReturn = new ClassVariable();
     $objToReturn->__blnRestored = true;
     $objToReturn->intId = $objDbRow->GetColumn($strAliasPrefix . 'id', 'Integer');
     $objToReturn->intQcodoClassId = $objDbRow->GetColumn($strAliasPrefix . 'qcodo_class_id', 'Integer');
     $objToReturn->intVariableGroupId = $objDbRow->GetColumn($strAliasPrefix . 'variable_group_id', 'Integer');
     $objToReturn->intProtectionTypeId = $objDbRow->GetColumn($strAliasPrefix . 'protection_type_id', 'Integer');
     $objToReturn->intVariableId = $objDbRow->GetColumn($strAliasPrefix . 'variable_id', 'Integer');
     $objToReturn->blnReadOnlyFlag = $objDbRow->GetColumn($strAliasPrefix . 'read_only_flag', 'Bit');
     $objToReturn->blnStaticFlag = $objDbRow->GetColumn($strAliasPrefix . 'static_flag', 'Bit');
     // Instantiate Virtual Attributes
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         $strVirtualPrefix = $strAliasPrefix . '__';
         $strVirtualPrefixLength = strlen($strVirtualPrefix);
         if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'class_variable__';
     }
     // Check for QcodoClass Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'qcodo_class_id__id'))) {
         $objToReturn->objQcodoClass = QcodoClass::InstantiateDbRow($objDbRow, $strAliasPrefix . 'qcodo_class_id__', $strExpandAsArrayNodes);
     }
     // Check for VariableGroup Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'variable_group_id__id'))) {
         $objToReturn->objVariableGroup = VariableGroup::InstantiateDbRow($objDbRow, $strAliasPrefix . 'variable_group_id__', $strExpandAsArrayNodes);
     }
     // Check for Variable Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'variable_id__id'))) {
         $objToReturn->objVariable = Variable::InstantiateDbRow($objDbRow, $strAliasPrefix . 'variable_id__', $strExpandAsArrayNodes);
     }
     // Check for ClassProperty Virtual Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'classproperty__id'))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'classproperty__id', $strExpandAsArrayNodes)) {
             array_push($objToReturn->_objClassPropertyArray, ClassProperty::InstantiateDbRow($objDbRow, $strAliasPrefix . 'classproperty__', $strExpandAsArrayNodes));
         } else {
             $objToReturn->_objClassProperty = ClassProperty::InstantiateDbRow($objDbRow, $strAliasPrefix . 'classproperty__', $strExpandAsArrayNodes);
         }
     }
     return $objToReturn;
 }
Esempio n. 3
0
 /**
  * Instantiate a ClassProperty from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this ClassProperty::InstantiateDbRow in order to perform
  * early binding on referenced objects.
  * @param DatabaseRowBase $objDbRow
  * @param string $strAliasPrefix
  * @return ClassProperty
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null)
 {
     // If blank row, return null
     if (!$objDbRow) {
         return null;
     }
     // Create a new instance of the ClassProperty object
     $objToReturn = new ClassProperty();
     $objToReturn->__blnRestored = true;
     $objToReturn->intId = $objDbRow->GetColumn($strAliasPrefix . 'id', 'Integer');
     $objToReturn->intQcodoClassId = $objDbRow->GetColumn($strAliasPrefix . 'qcodo_class_id', 'Integer');
     $objToReturn->intVariableGroupId = $objDbRow->GetColumn($strAliasPrefix . 'variable_group_id', 'Integer');
     $objToReturn->intVariableId = $objDbRow->GetColumn($strAliasPrefix . 'variable_id', 'Integer');
     $objToReturn->intClassVariableId = $objDbRow->GetColumn($strAliasPrefix . 'class_variable_id', 'Integer');
     $objToReturn->blnReadOnlyFlag = $objDbRow->GetColumn($strAliasPrefix . 'read_only_flag', 'Bit');
     $objToReturn->blnWriteOnlyFlag = $objDbRow->GetColumn($strAliasPrefix . 'write_only_flag', 'Bit');
     // Instantiate Virtual Attributes
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         $strVirtualPrefix = $strAliasPrefix . '__';
         $strVirtualPrefixLength = strlen($strVirtualPrefix);
         if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'class_property__';
     }
     // Check for QcodoClass Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'qcodo_class_id__id'))) {
         $objToReturn->objQcodoClass = QcodoClass::InstantiateDbRow($objDbRow, $strAliasPrefix . 'qcodo_class_id__', $strExpandAsArrayNodes);
     }
     // Check for VariableGroup Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'variable_group_id__id'))) {
         $objToReturn->objVariableGroup = VariableGroup::InstantiateDbRow($objDbRow, $strAliasPrefix . 'variable_group_id__', $strExpandAsArrayNodes);
     }
     // Check for Variable Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'variable_id__id'))) {
         $objToReturn->objVariable = Variable::InstantiateDbRow($objDbRow, $strAliasPrefix . 'variable_id__', $strExpandAsArrayNodes);
     }
     // Check for ClassVariable Early Binding
     if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'class_variable_id__id'))) {
         $objToReturn->objClassVariable = ClassVariable::InstantiateDbRow($objDbRow, $strAliasPrefix . 'class_variable_id__', $strExpandAsArrayNodes);
     }
     return $objToReturn;
 }