/** * Instantiate a ParentPagerChildHistory from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this ParentPagerChildHistory::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 ParentPagerChildHistory */ public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array()) { // If blank row, return null if (!$objDbRow) { return null; } // Create a new instance of the ParentPagerChildHistory object $objToReturn = new ParentPagerChildHistory(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id'; $objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'server_identifier', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'server_identifier'] : $strAliasPrefix . 'server_identifier'; $objToReturn->intServerIdentifier = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'parent_pager_individual_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'parent_pager_individual_id'] : $strAliasPrefix . 'parent_pager_individual_id'; $objToReturn->intParentPagerIndividualId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'parent_pager_station_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'parent_pager_station_id'] : $strAliasPrefix . 'parent_pager_station_id'; $objToReturn->intParentPagerStationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'parent_pager_period_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'parent_pager_period_id'] : $strAliasPrefix . 'parent_pager_period_id'; $objToReturn->intParentPagerPeriodId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'dropoff_by_parent_pager_individual_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'dropoff_by_parent_pager_individual_id'] : $strAliasPrefix . 'dropoff_by_parent_pager_individual_id'; $objToReturn->intDropoffByParentPagerIndividualId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'pickup_by_parent_pager_individual_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'pickup_by_parent_pager_individual_id'] : $strAliasPrefix . 'pickup_by_parent_pager_individual_id'; $objToReturn->intPickupByParentPagerIndividualId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'date_in', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'date_in'] : $strAliasPrefix . 'date_in'; $objToReturn->dttDateIn = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'date_out', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'date_out'] : $strAliasPrefix . 'date_out'; $objToReturn->dttDateOut = $objDbRow->GetColumn($strAliasName, 'DateTime'); // 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 = 'parent_pager_child_history__'; } // Check for ParentPagerIndividual Early Binding $strAlias = $strAliasPrefix . 'parent_pager_individual_id__id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objParentPagerIndividual = ParentPagerIndividual::InstantiateDbRow($objDbRow, $strAliasPrefix . 'parent_pager_individual_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ParentPagerStation Early Binding $strAlias = $strAliasPrefix . 'parent_pager_station_id__id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objParentPagerStation = ParentPagerStation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'parent_pager_station_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ParentPagerPeriod Early Binding $strAlias = $strAliasPrefix . 'parent_pager_period_id__id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objParentPagerPeriod = ParentPagerPeriod::InstantiateDbRow($objDbRow, $strAliasPrefix . 'parent_pager_period_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for DropoffByParentPagerIndividual Early Binding $strAlias = $strAliasPrefix . 'dropoff_by_parent_pager_individual_id__id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objDropoffByParentPagerIndividual = ParentPagerIndividual::InstantiateDbRow($objDbRow, $strAliasPrefix . 'dropoff_by_parent_pager_individual_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for PickupByParentPagerIndividual Early Binding $strAlias = $strAliasPrefix . 'pickup_by_parent_pager_individual_id__id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objPickupByParentPagerIndividual = ParentPagerIndividual::InstantiateDbRow($objDbRow, $strAliasPrefix . 'pickup_by_parent_pager_individual_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } return $objToReturn; }
/** * Instantiate a single ParentPagerPeriod 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 ParentPagerPeriod 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 ParentPagerPeriod::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray); }