/** * Instantiate an array of PackageTypes from a Database Result * @param DatabaseResultBase $objDbResult * @return PackageType[] */ 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 = PackageType::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem); if ($objItem) { array_push($objToReturn, $objItem); $objLastRowItem = $objItem; } } } else { while ($objDbRow = $objDbResult->GetNextRow()) { array_push($objToReturn, PackageType::InstantiateDbRow($objDbRow)); } } return $objToReturn; }
/** * Instantiate a FedexShipment from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this FedexShipment::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return FedexShipment */ 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 FedexShipment object $objToReturn = new FedexShipment(); $objToReturn->__blnRestored = true; $objToReturn->intFedexShipmentId = $objDbRow->GetColumn($strAliasPrefix . 'fedex_shipment_id', 'Integer'); $objToReturn->intShipmentId = $objDbRow->GetColumn($strAliasPrefix . 'shipment_id', 'Integer'); $objToReturn->intPackageTypeId = $objDbRow->GetColumn($strAliasPrefix . 'package_type_id', 'Integer'); $objToReturn->intShippingAccountId = $objDbRow->GetColumn($strAliasPrefix . 'shipping_account_id', 'Integer'); $objToReturn->intFedexServiceTypeId = $objDbRow->GetColumn($strAliasPrefix . 'fedex_service_type_id', 'Integer'); $objToReturn->intCurrencyUnitId = $objDbRow->GetColumn($strAliasPrefix . 'currency_unit_id', 'Integer'); $objToReturn->intWeightUnitId = $objDbRow->GetColumn($strAliasPrefix . 'weight_unit_id', 'Integer'); $objToReturn->intLengthUnitId = $objDbRow->GetColumn($strAliasPrefix . 'length_unit_id', 'Integer'); $objToReturn->strToPhone = $objDbRow->GetColumn($strAliasPrefix . 'to_phone', 'VarChar'); $objToReturn->intPayType = $objDbRow->GetColumn($strAliasPrefix . 'pay_type', 'Integer'); $objToReturn->strPayerAccountNumber = $objDbRow->GetColumn($strAliasPrefix . 'payer_account_number', 'VarChar'); $objToReturn->fltPackageWeight = $objDbRow->GetColumn($strAliasPrefix . 'package_weight', 'Float'); $objToReturn->fltPackageLength = $objDbRow->GetColumn($strAliasPrefix . 'package_length', 'Float'); $objToReturn->fltPackageWidth = $objDbRow->GetColumn($strAliasPrefix . 'package_width', 'Float'); $objToReturn->fltPackageHeight = $objDbRow->GetColumn($strAliasPrefix . 'package_height', 'Float'); $objToReturn->fltDeclaredValue = $objDbRow->GetColumn($strAliasPrefix . 'declared_value', 'Float'); $objToReturn->strReference = $objDbRow->GetColumn($strAliasPrefix . 'reference', 'Blob'); $objToReturn->blnSaturdayDeliveryFlag = $objDbRow->GetColumn($strAliasPrefix . 'saturday_delivery_flag', 'Bit'); $objToReturn->strNotifySenderEmail = $objDbRow->GetColumn($strAliasPrefix . 'notify_sender_email', 'VarChar'); $objToReturn->blnNotifySenderShipFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_sender_ship_flag', 'Bit'); $objToReturn->blnNotifySenderExceptionFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_sender_exception_flag', 'Bit'); $objToReturn->blnNotifySenderDeliveryFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_sender_delivery_flag', 'Bit'); $objToReturn->strNotifyRecipientEmail = $objDbRow->GetColumn($strAliasPrefix . 'notify_recipient_email', 'VarChar'); $objToReturn->blnNotifyRecipientShipFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_recipient_ship_flag', 'Bit'); $objToReturn->blnNotifyRecipientExceptionFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_recipient_exception_flag', 'Bit'); $objToReturn->blnNotifyRecipientDeliveryFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_recipient_delivery_flag', 'Bit'); $objToReturn->strNotifyOtherEmail = $objDbRow->GetColumn($strAliasPrefix . 'notify_other_email', 'VarChar'); $objToReturn->blnNotifyOtherShipFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_other_ship_flag', 'Bit'); $objToReturn->blnNotifyOtherExceptionFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_other_exception_flag', 'Bit'); $objToReturn->blnNotifyOtherDeliveryFlag = $objDbRow->GetColumn($strAliasPrefix . 'notify_other_delivery_flag', 'Bit'); $objToReturn->blnHoldAtLocationFlag = $objDbRow->GetColumn($strAliasPrefix . 'hold_at_location_flag', 'Bit'); $objToReturn->strHoldAtLocationAddress = $objDbRow->GetColumn($strAliasPrefix . 'hold_at_location_address', 'VarChar'); $objToReturn->strHoldAtLocationCity = $objDbRow->GetColumn($strAliasPrefix . 'hold_at_location_city', 'VarChar'); $objToReturn->intHoldAtLocationState = $objDbRow->GetColumn($strAliasPrefix . 'hold_at_location_state', 'Integer'); $objToReturn->strHoldAtLocationPostalCode = $objDbRow->GetColumn($strAliasPrefix . 'hold_at_location_postal_code', '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 = 'fedex_shipment__'; } // Check for Shipment Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shipment_id__shipment_id'))) { $objToReturn->objShipment = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipment_id__', $strExpandAsArrayNodes); } // Check for PackageType Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'package_type_id__package_type_id'))) { $objToReturn->objPackageType = PackageType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'package_type_id__', $strExpandAsArrayNodes); } // Check for ShippingAccount Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shipping_account_id__shipping_account_id'))) { $objToReturn->objShippingAccount = ShippingAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipping_account_id__', $strExpandAsArrayNodes); } // Check for FedexServiceType Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'fedex_service_type_id__fedex_service_type_id'))) { $objToReturn->objFedexServiceType = FedexServiceType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'fedex_service_type_id__', $strExpandAsArrayNodes); } // Check for CurrencyUnit Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'currency_unit_id__currency_unit_id'))) { $objToReturn->objCurrencyUnit = CurrencyUnit::InstantiateDbRow($objDbRow, $strAliasPrefix . 'currency_unit_id__', $strExpandAsArrayNodes); } // Check for WeightUnit Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'weight_unit_id__weight_unit_id'))) { $objToReturn->objWeightUnit = WeightUnit::InstantiateDbRow($objDbRow, $strAliasPrefix . 'weight_unit_id__', $strExpandAsArrayNodes); } // Check for LengthUnit Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'length_unit_id__length_unit_id'))) { $objToReturn->objLengthUnit = LengthUnit::InstantiateDbRow($objDbRow, $strAliasPrefix . 'length_unit_id__', $strExpandAsArrayNodes); } // Check for HoldAtLocationStateObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'hold_at_location_state__state_province_id'))) { $objToReturn->objHoldAtLocationStateObject = StateProvince::InstantiateDbRow($objDbRow, $strAliasPrefix . 'hold_at_location_state__', $strExpandAsArrayNodes); } return $objToReturn; }
/** * Instantiate a Courier from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Courier::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Courier */ 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->intCourierId == $objDbRow->GetColumn($strAliasPrefix . 'courier_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'courier__'; } if (array_key_exists($strAliasPrefix . 'packagetype__package_type_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'packagetype__package_type_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objPackageTypeArray)) { $objPreviousChildItem = $objPreviousItem->_objPackageTypeArray[$intPreviousChildItemCount - 1]; $objChildItem = PackageType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'packagetype__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objPackageTypeArray, $objChildItem); } } else { array_push($objPreviousItem->_objPackageTypeArray, PackageType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'packagetype__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'shipment__shipment_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'shipment__shipment_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objShipmentArray)) { $objPreviousChildItem = $objPreviousItem->_objShipmentArray[$intPreviousChildItemCount - 1]; $objChildItem = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipment__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objShipmentArray, $objChildItem); } } else { array_push($objPreviousItem->_objShipmentArray, Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipment__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'shippingaccount__shipping_account_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'shippingaccount__shipping_account_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objShippingAccountArray)) { $objPreviousChildItem = $objPreviousItem->_objShippingAccountArray[$intPreviousChildItemCount - 1]; $objChildItem = ShippingAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shippingaccount__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objShippingAccountArray, $objChildItem); } } else { array_push($objPreviousItem->_objShippingAccountArray, ShippingAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shippingaccount__', $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 == 'courier__') { $strAliasPrefix = null; } } } // Create a new instance of the Courier object $objToReturn = new Courier(); $objToReturn->__blnRestored = true; $objToReturn->intCourierId = $objDbRow->GetColumn($strAliasPrefix . 'courier_id', 'Integer'); $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasPrefix . 'short_description', 'VarChar'); $objToReturn->blnActiveFlag = $objDbRow->GetColumn($strAliasPrefix . 'active_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 = 'courier__'; } // Check for PackageType Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'packagetype__package_type_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'packagetype__package_type_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objPackageTypeArray, PackageType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'packagetype__', $strExpandAsArrayNodes)); } else { $objToReturn->_objPackageType = PackageType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'packagetype__', $strExpandAsArrayNodes); } } // Check for Shipment Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shipment__shipment_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'shipment__shipment_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objShipmentArray, Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipment__', $strExpandAsArrayNodes)); } else { $objToReturn->_objShipment = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipment__', $strExpandAsArrayNodes); } } // Check for ShippingAccount Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shippingaccount__shipping_account_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'shippingaccount__shipping_account_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objShippingAccountArray, ShippingAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shippingaccount__', $strExpandAsArrayNodes)); } else { $objToReturn->_objShippingAccount = ShippingAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shippingaccount__', $strExpandAsArrayNodes); } } return $objToReturn; }