/** * 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 an array of WeightUnits from a Database Result * @param DatabaseResultBase $objDbResult * @return WeightUnit[] */ 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 = WeightUnit::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem); if ($objItem) { array_push($objToReturn, $objItem); $objLastRowItem = $objItem; } } } else { while ($objDbRow = $objDbResult->GetNextRow()) { array_push($objToReturn, WeightUnit::InstantiateDbRow($objDbRow)); } } return $objToReturn; }