Esempio n. 1
0
 /**
  * Instantiate a single GrowthGroupLocation object from a query cursor (e.g. a DB ResultSet).
  * Cursor is automatically moved to the "next row" of the result set.
  * Will return NULL if no cursor or if the cursor has no more rows in the resultset.
  * @param QDatabaseResultBase $objDbResult cursor resource
  * @return GrowthGroupLocation next row resulting from the query
  */
 public static function InstantiateCursor(QDatabaseResultBase $objDbResult)
 {
     // If blank resultset, then return empty result
     if (!$objDbResult) {
         return null;
     }
     // If empty resultset, then return empty result
     $objDbRow = $objDbResult->GetNextRow();
     if (!$objDbRow) {
         return null;
     }
     // We need the Column Aliases
     $strColumnAliasArray = $objDbResult->QueryBuilder->ColumnAliasArray;
     if (!$strColumnAliasArray) {
         $strColumnAliasArray = array();
     }
     // Pull Expansions (if applicable)
     $strExpandAsArrayNodes = $objDbResult->QueryBuilder->ExpandAsArrayNodes;
     // Load up the return result with a row and return it
     return GrowthGroupLocation::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }
Esempio n. 2
0
 /**
  * Instantiate a GrowthGroup from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this GrowthGroup::InstantiateDbRow in order to perform
  * early binding on referenced objects.
  * @param QDatabaseRowBase $objDbRow
  * @param string $strAliasPrefix
  * @param string $strExpandAsArrayNodes
  * @param QBaseClass $objPreviousItem
  * @param string[] $strColumnAliasArray
  * @return GrowthGroup
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array())
 {
     // If blank row, return null
     if (!$objDbRow) {
         return null;
     }
     // See if we're doing an array expansion on the previous item
     $strAlias = $strAliasPrefix . 'group_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intGroupId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
         // We are.  Now, prepare to check for ExpandAsArray clauses
         $blnExpandedViaArray = false;
         if (!$strAliasPrefix) {
             $strAliasPrefix = 'growth_group__';
         }
         $strAlias = $strAliasPrefix . 'growthgroupstructure__growth_group_structure_id__id';
         $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
         if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
             if ($intPreviousChildItemCount = count($objPreviousItem->_objGrowthGroupStructureArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objGrowthGroupStructureArray[$intPreviousChildItemCount - 1];
                 $objChildItem = GrowthGroupStructure::InstantiateDbRow($objDbRow, $strAliasPrefix . 'growthgroupstructure__growth_group_structure_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objGrowthGroupStructureArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objGrowthGroupStructureArray[] = GrowthGroupStructure::InstantiateDbRow($objDbRow, $strAliasPrefix . 'growthgroupstructure__growth_group_structure_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $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 == 'growth_group__') {
                 $strAliasPrefix = null;
             }
         }
     }
     // Create a new instance of the GrowthGroup object
     $objToReturn = new GrowthGroup();
     $objToReturn->__blnRestored = true;
     $strAliasName = array_key_exists($strAliasPrefix . 'group_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'group_id'] : $strAliasPrefix . 'group_id';
     $objToReturn->intGroupId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $objToReturn->__intGroupId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'growth_group_location_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'growth_group_location_id'] : $strAliasPrefix . 'growth_group_location_id';
     $objToReturn->intGrowthGroupLocationId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'growth_group_day_type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'growth_group_day_type_id'] : $strAliasPrefix . 'growth_group_day_type_id';
     $objToReturn->intGrowthGroupDayTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'meeting_bitmap', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'meeting_bitmap'] : $strAliasPrefix . 'meeting_bitmap';
     $objToReturn->intMeetingBitmap = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'start_time', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'start_time'] : $strAliasPrefix . 'start_time';
     $objToReturn->intStartTime = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'end_time', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'end_time'] : $strAliasPrefix . 'end_time';
     $objToReturn->intEndTime = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'address_1', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'address_1'] : $strAliasPrefix . 'address_1';
     $objToReturn->strAddress1 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'address_2', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'address_2'] : $strAliasPrefix . 'address_2';
     $objToReturn->strAddress2 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'cross_street_1', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'cross_street_1'] : $strAliasPrefix . 'cross_street_1';
     $objToReturn->strCrossStreet1 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'cross_street_2', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'cross_street_2'] : $strAliasPrefix . 'cross_street_2';
     $objToReturn->strCrossStreet2 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'zip_code', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'zip_code'] : $strAliasPrefix . 'zip_code';
     $objToReturn->strZipCode = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'longitude', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'longitude'] : $strAliasPrefix . 'longitude';
     $objToReturn->fltLongitude = $objDbRow->GetColumn($strAliasName, 'Float');
     $strAliasName = array_key_exists($strAliasPrefix . 'latitude', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'latitude'] : $strAliasPrefix . 'latitude';
     $objToReturn->fltLatitude = $objDbRow->GetColumn($strAliasName, 'Float');
     $strAliasName = array_key_exists($strAliasPrefix . 'accuracy', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'accuracy'] : $strAliasPrefix . 'accuracy';
     $objToReturn->intAccuracy = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'description'] : $strAliasPrefix . 'description';
     $objToReturn->strDescription = $objDbRow->GetColumn($strAliasName, 'VarChar');
     // 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 = 'growth_group__';
     }
     // Check for Group Early Binding
     $strAlias = $strAliasPrefix . 'group_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objGroup = Group::InstantiateDbRow($objDbRow, $strAliasPrefix . 'group_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for GrowthGroupLocation Early Binding
     $strAlias = $strAliasPrefix . 'growth_group_location_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objGrowthGroupLocation = GrowthGroupLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'growth_group_location_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for GrowthGroupStructure Virtual Binding
     $strAlias = $strAliasPrefix . 'growthgroupstructure__growth_group_structure_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objGrowthGroupStructureArray[] = GrowthGroupStructure::InstantiateDbRow($objDbRow, $strAliasPrefix . 'growthgroupstructure__growth_group_structure_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objGrowthGroupStructure = GrowthGroupStructure::InstantiateDbRow($objDbRow, $strAliasPrefix . 'growthgroupstructure__growth_group_structure_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }