/** * Instantiate a Asset from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Asset::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Asset */ 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->intAssetId == $objDbRow->GetColumn($strAliasPrefix . 'asset_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'asset__'; } if (array_key_exists($strAliasPrefix . 'assettransaction__asset_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransaction__asset_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAssetTransactionArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAssetTransactionArray, $objChildItem); } } else { array_push($objPreviousItem->_objAssetTransactionArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'assettransactionasnew__asset_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransactionasnew__asset_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAssetTransactionAsNewArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionAsNewArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAssetTransactionAsNewArray, $objChildItem); } } else { array_push($objPreviousItem->_objAssetTransactionAsNewArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $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 == 'asset__') { $strAliasPrefix = null; } } } // Create a new instance of the Asset object $objToReturn = new Asset(); $objToReturn->__blnRestored = true; $objToReturn->intAssetId = $objDbRow->GetColumn($strAliasPrefix . 'asset_id', 'Integer'); $objToReturn->intAssetModelId = $objDbRow->GetColumn($strAliasPrefix . 'asset_model_id', 'Integer'); $objToReturn->intLocationId = $objDbRow->GetColumn($strAliasPrefix . 'location_id', 'Integer'); $objToReturn->strAssetCode = $objDbRow->GetColumn($strAliasPrefix . 'asset_code', 'VarChar'); $objToReturn->strImagePath = $objDbRow->GetColumn($strAliasPrefix . 'image_path', 'VarChar'); $objToReturn->blnCheckedOutFlag = $objDbRow->GetColumn($strAliasPrefix . 'checked_out_flag', 'Bit'); $objToReturn->blnReservedFlag = $objDbRow->GetColumn($strAliasPrefix . 'reserved_flag', 'Bit'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'asset__'; } // Check for AssetModel Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'asset_model_id__asset_model_id'))) { $objToReturn->objAssetModel = AssetModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset_model_id__', $strExpandAsArrayNodes); } // Check for Location Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'location_id__location_id'))) { $objToReturn->objLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'location_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for AssetTransaction Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransaction__asset_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'assettransaction__asset_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAssetTransactionArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAssetTransaction = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes); } } // Check for AssetTransactionAsNew Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransactionasnew__asset_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'assettransactionasnew__asset_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAssetTransactionAsNewArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAssetTransactionAsNew = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a Asset from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Asset::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 Asset */ 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 . 'asset_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intAssetId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'asset__'; } $strAlias = $strAliasPrefix . 'childasset__asset_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->_objChildAssetArray)) { $objPreviousChildItem = $objPreviousItem->_objChildAssetArray[$intPreviousChildItemCount - 1]; $objChildItem = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childasset__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objChildAssetArray[] = $objChildItem; } } else { $objPreviousItem->_objChildAssetArray[] = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childasset__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'assettransaction__asset_transaction_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->_objAssetTransactionArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objAssetTransactionArray[] = $objChildItem; } } else { $objPreviousItem->_objAssetTransactionArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'assettransactionasnew__asset_transaction_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->_objAssetTransactionAsNewArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionAsNewArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objAssetTransactionAsNewArray[] = $objChildItem; } } else { $objPreviousItem->_objAssetTransactionAsNewArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $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 == 'asset__') { $strAliasPrefix = null; } } } // Create a new instance of the Asset object $objToReturn = new Asset(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'asset_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_id'] : $strAliasPrefix . 'asset_id'; $objToReturn->intAssetId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'parent_asset_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'parent_asset_id'] : $strAliasPrefix . 'parent_asset_id'; $objToReturn->intParentAssetId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'asset_model_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_model_id'] : $strAliasPrefix . 'asset_model_id'; $objToReturn->intAssetModelId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'location_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'location_id'] : $strAliasPrefix . 'location_id'; $objToReturn->intLocationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'asset_code', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_code'] : $strAliasPrefix . 'asset_code'; $objToReturn->strAssetCode = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'image_path', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'image_path'] : $strAliasPrefix . 'image_path'; $objToReturn->strImagePath = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'checked_out_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'checked_out_flag'] : $strAliasPrefix . 'checked_out_flag'; $objToReturn->blnCheckedOutFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'reserved_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'reserved_flag'] : $strAliasPrefix . 'reserved_flag'; $objToReturn->blnReservedFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'linked_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'linked_flag'] : $strAliasPrefix . 'linked_flag'; $objToReturn->blnLinkedFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'archived_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'archived_flag'] : $strAliasPrefix . 'archived_flag'; $objToReturn->blnArchivedFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'depreciation_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'depreciation_flag'] : $strAliasPrefix . 'depreciation_flag'; $objToReturn->blnDepreciationFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'purchase_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'purchase_date'] : $strAliasPrefix . 'purchase_date'; $objToReturn->dttPurchaseDate = $objDbRow->GetColumn($strAliasName, 'Date'); $strAliasName = array_key_exists($strAliasPrefix . 'purchase_cost', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'purchase_cost'] : $strAliasPrefix . 'purchase_cost'; $objToReturn->fltPurchaseCost = $objDbRow->GetColumn($strAliasName, 'Float'); // 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 = 'asset__'; } // Check for ParentAsset Early Binding $strAlias = $strAliasPrefix . 'parent_asset_id__asset_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objParentAsset = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'parent_asset_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for AssetModel Early Binding $strAlias = $strAliasPrefix . 'asset_model_id__asset_model_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAssetModel = AssetModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset_model_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for Location Early Binding $strAlias = $strAliasPrefix . 'location_id__location_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'location_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for AssetCustomFieldHelper Unique ReverseReference Binding $strAlias = $strAliasPrefix . 'assetcustomfieldhelper__asset_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($objDbRow->ColumnExists($strAliasName)) { if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAssetCustomFieldHelper = AssetCustomFieldHelper::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assetcustomfieldhelper__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objAssetCustomFieldHelper = false; } } // Check for ChildAsset Virtual Binding $strAlias = $strAliasPrefix . 'childasset__asset_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objChildAssetArray[] = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childasset__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objChildAsset = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childasset__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for AssetTransaction Virtual Binding $strAlias = $strAliasPrefix . 'assettransaction__asset_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objAssetTransactionArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objAssetTransaction = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for AssetTransactionAsNew Virtual Binding $strAlias = $strAliasPrefix . 'assettransactionasnew__asset_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objAssetTransactionAsNewArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objAssetTransactionAsNew = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasnew__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a Attachment from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Attachment::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Attachment */ 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 Attachment object $objToReturn = new Attachment(); $objToReturn->__blnRestored = true; $objToReturn->intAttachmentId = $objDbRow->GetColumn($strAliasPrefix . 'attachment_id', 'Integer'); $objToReturn->intEntityQtypeId = $objDbRow->GetColumn($strAliasPrefix . 'entity_qtype_id', 'Integer'); $objToReturn->intEntityId = $objDbRow->GetColumn($strAliasPrefix . 'entity_id', 'Integer'); $objToReturn->strFilename = $objDbRow->GetColumn($strAliasPrefix . 'filename', 'VarChar'); $objToReturn->strTmpFilename = $objDbRow->GetColumn($strAliasPrefix . 'tmp_filename', 'VarChar'); $objToReturn->strFileType = $objDbRow->GetColumn($strAliasPrefix . 'file_type', 'VarChar'); $objToReturn->strPath = $objDbRow->GetColumn($strAliasPrefix . 'path', 'VarChar'); $objToReturn->intSize = $objDbRow->GetColumn($strAliasPrefix . 'SIZE', 'Integer'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', '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 = 'attachment__'; } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } return $objToReturn; }
/** * Instantiate a ShippingAccount from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this ShippingAccount::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return ShippingAccount */ 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->intShippingAccountId == $objDbRow->GetColumn($strAliasPrefix . 'shipping_account_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'shipping_account__'; } if (array_key_exists($strAliasPrefix . 'fedexshipment__fedex_shipment_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'fedexshipment__fedex_shipment_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objFedexShipmentArray)) { $objPreviousChildItem = $objPreviousItem->_objFedexShipmentArray[$intPreviousChildItemCount - 1]; $objChildItem = FedexShipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'fedexshipment__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objFedexShipmentArray, $objChildItem); } } else { array_push($objPreviousItem->_objFedexShipmentArray, FedexShipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'fedexshipment__', $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 == 'shipping_account__') { $strAliasPrefix = null; } } } // Create a new instance of the ShippingAccount object $objToReturn = new ShippingAccount(); $objToReturn->__blnRestored = true; $objToReturn->intShippingAccountId = $objDbRow->GetColumn($strAliasPrefix . 'shipping_account_id', 'Integer'); $objToReturn->intCourierId = $objDbRow->GetColumn($strAliasPrefix . 'courier_id', 'Integer'); $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasPrefix . 'short_description', 'VarChar'); $objToReturn->strAccessId = $objDbRow->GetColumn($strAliasPrefix . 'access_id', 'VarChar'); $objToReturn->strAccessCode = $objDbRow->GetColumn($strAliasPrefix . 'access_code', 'VarChar'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'shipping_account__'; } // Check for Courier Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'courier_id__courier_id'))) { $objToReturn->objCourier = Courier::InstantiateDbRow($objDbRow, $strAliasPrefix . 'courier_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for FedexShipment Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'fedexshipment__fedex_shipment_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'fedexshipment__fedex_shipment_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objFedexShipmentArray, FedexShipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'fedexshipment__', $strExpandAsArrayNodes)); } else { $objToReturn->_objFedexShipment = FedexShipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'fedexshipment__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a InventoryModel from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this InventoryModel::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return InventoryModel */ 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->intInventoryModelId == $objDbRow->GetColumn($strAliasPrefix . 'inventory_model_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'inventory_model__'; } if (array_key_exists($strAliasPrefix . 'inventorylocation__inventory_location_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorylocation__inventory_location_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objInventoryLocationArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryLocationArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objInventoryLocationArray, $objChildItem); } } else { array_push($objPreviousItem->_objInventoryLocationArray, InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $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 == 'inventory_model__') { $strAliasPrefix = null; } } } // Create a new instance of the InventoryModel object $objToReturn = new InventoryModel(); $objToReturn->__blnRestored = true; $objToReturn->intInventoryModelId = $objDbRow->GetColumn($strAliasPrefix . 'inventory_model_id', 'Integer'); $objToReturn->intCategoryId = $objDbRow->GetColumn($strAliasPrefix . 'category_id', 'Integer'); $objToReturn->intManufacturerId = $objDbRow->GetColumn($strAliasPrefix . 'manufacturer_id', 'Integer'); $objToReturn->strInventoryModelCode = $objDbRow->GetColumn($strAliasPrefix . 'inventory_model_code', 'VarChar'); $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasPrefix . 'short_description', 'VarChar'); $objToReturn->strLongDescription = $objDbRow->GetColumn($strAliasPrefix . 'long_description', 'Blob'); $objToReturn->strImagePath = $objDbRow->GetColumn($strAliasPrefix . 'image_path', 'VarChar'); $objToReturn->fltPrice = $objDbRow->GetColumn($strAliasPrefix . 'price', 'Float'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'inventory_model__'; } // Check for Category Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'category_id__category_id'))) { $objToReturn->objCategory = Category::InstantiateDbRow($objDbRow, $strAliasPrefix . 'category_id__', $strExpandAsArrayNodes); } // Check for Manufacturer Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'manufacturer_id__manufacturer_id'))) { $objToReturn->objManufacturer = Manufacturer::InstantiateDbRow($objDbRow, $strAliasPrefix . 'manufacturer_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for InventoryLocation Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorylocation__inventory_location_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'inventorylocation__inventory_location_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objInventoryLocationArray, InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes)); } else { $objToReturn->_objInventoryLocation = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a Notification from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Notification::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 Notification */ 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 . 'notification_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intNotificationId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'notification__'; } $strAlias = $strAliasPrefix . 'notificationuseraccount__notification_user_account_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->_objNotificationUserAccountArray)) { $objPreviousChildItem = $objPreviousItem->_objNotificationUserAccountArray[$intPreviousChildItemCount - 1]; $objChildItem = NotificationUserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'notificationuseraccount__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objNotificationUserAccountArray[] = $objChildItem; } } else { $objPreviousItem->_objNotificationUserAccountArray[] = NotificationUserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'notificationuseraccount__', $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 == 'notification__') { $strAliasPrefix = null; } } } // Create a new instance of the Notification object $objToReturn = new Notification(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'notification_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'notification_id'] : $strAliasPrefix . 'notification_id'; $objToReturn->intNotificationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'short_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'short_description'] : $strAliasPrefix . 'short_description'; $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'long_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'long_description'] : $strAliasPrefix . 'long_description'; $objToReturn->strLongDescription = $objDbRow->GetColumn($strAliasName, 'Blob'); $strAliasName = array_key_exists($strAliasPrefix . 'criteria', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'criteria'] : $strAliasPrefix . 'criteria'; $objToReturn->strCriteria = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'frequency', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'frequency'] : $strAliasPrefix . 'frequency'; $objToReturn->strFrequency = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'enabled_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'enabled_flag'] : $strAliasPrefix . 'enabled_flag'; $objToReturn->blnEnabledFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'notification__'; } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for NotificationUserAccount Virtual Binding $strAlias = $strAliasPrefix . 'notificationuseraccount__notification_user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objNotificationUserAccountArray[] = NotificationUserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'notificationuseraccount__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objNotificationUserAccount = NotificationUserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'notificationuseraccount__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a DatagridColumnPreference from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this DatagridColumnPreference::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return DatagridColumnPreference */ 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 DatagridColumnPreference object $objToReturn = new DatagridColumnPreference(); $objToReturn->__blnRestored = true; $objToReturn->intDatagridColumnPreferenceId = $objDbRow->GetColumn($strAliasPrefix . 'datagrid_column_preference_id', 'Integer'); $objToReturn->intDatagridId = $objDbRow->GetColumn($strAliasPrefix . 'datagrid_id', 'Integer'); $objToReturn->strColumnName = $objDbRow->GetColumn($strAliasPrefix . 'column_name', 'VarChar'); $objToReturn->intUserAccountId = $objDbRow->GetColumn($strAliasPrefix . 'user_account_id', 'Integer'); $objToReturn->blnDisplayFlag = $objDbRow->GetColumn($strAliasPrefix . 'display_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 = 'datagrid_column_preference__'; } // Check for Datagrid Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'datagrid_id__datagrid_id'))) { $objToReturn->objDatagrid = Datagrid::InstantiateDbRow($objDbRow, $strAliasPrefix . 'datagrid_id__', $strExpandAsArrayNodes); } // Check for UserAccount Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'user_account_id__user_account_id'))) { $objToReturn->objUserAccount = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'user_account_id__', $strExpandAsArrayNodes); } return $objToReturn; }
/** * Instantiate a Transaction from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Transaction::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Transaction */ 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->intTransactionId == $objDbRow->GetColumn($strAliasPrefix . 'transaction_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'transaction__'; } if (array_key_exists($strAliasPrefix . 'assettransaction__asset_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransaction__asset_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAssetTransactionArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAssetTransactionArray, $objChildItem); } } else { array_push($objPreviousItem->_objAssetTransactionArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'inventorytransaction__inventory_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorytransaction__inventory_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objInventoryTransactionArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryTransactionArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objInventoryTransactionArray, $objChildItem); } } else { array_push($objPreviousItem->_objInventoryTransactionArray, InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $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 == 'transaction__') { $strAliasPrefix = null; } } } // Create a new instance of the Transaction object $objToReturn = new Transaction(); $objToReturn->__blnRestored = true; $objToReturn->intTransactionId = $objDbRow->GetColumn($strAliasPrefix . 'transaction_id', 'Integer'); $objToReturn->intEntityQtypeId = $objDbRow->GetColumn($strAliasPrefix . 'entity_qtype_id', 'Integer'); $objToReturn->intTransactionTypeId = $objDbRow->GetColumn($strAliasPrefix . 'transaction_type_id', 'Integer'); $objToReturn->strNote = $objDbRow->GetColumn($strAliasPrefix . 'note', 'Blob'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'transaction__'; } // Check for TransactionType Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'transaction_type_id__transaction_type_id'))) { $objToReturn->objTransactionType = TransactionType::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transaction_type_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for Receipt Unique ReverseReference Binding if ($objDbRow->ColumnExists($strAliasPrefix . 'receipt__receipt_id')) { if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'receipt__receipt_id'))) { $objToReturn->objReceipt = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receipt__', $strExpandAsArrayNodes); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objReceipt = false; } } // Check for Shipment Unique ReverseReference Binding if ($objDbRow->ColumnExists($strAliasPrefix . 'shipment__shipment_id')) { if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shipment__shipment_id'))) { $objToReturn->objShipment = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipment__', $strExpandAsArrayNodes); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objShipment = false; } } // Check for AssetTransaction Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransaction__asset_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'assettransaction__asset_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAssetTransactionArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAssetTransaction = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransaction__', $strExpandAsArrayNodes); } } // Check for InventoryTransaction Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorytransaction__inventory_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'inventorytransaction__inventory_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objInventoryTransactionArray, InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $strExpandAsArrayNodes)); } else { $objToReturn->_objInventoryTransaction = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a InventoryTransaction from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this InventoryTransaction::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return InventoryTransaction */ 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 InventoryTransaction object $objToReturn = new InventoryTransaction(); $objToReturn->__blnRestored = true; $objToReturn->intInventoryTransactionId = $objDbRow->GetColumn($strAliasPrefix . 'inventory_transaction_id', 'Integer'); $objToReturn->intInventoryLocationId = $objDbRow->GetColumn($strAliasPrefix . 'inventory_location_id', 'Integer'); $objToReturn->intTransactionId = $objDbRow->GetColumn($strAliasPrefix . 'transaction_id', 'Integer'); $objToReturn->intQuantity = $objDbRow->GetColumn($strAliasPrefix . 'quantity', 'Integer'); $objToReturn->intSourceLocationId = $objDbRow->GetColumn($strAliasPrefix . 'source_location_id', 'Integer'); $objToReturn->intDestinationLocationId = $objDbRow->GetColumn($strAliasPrefix . 'destination_location_id', 'Integer'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', 'VarChar'); $objToReturn->intLocalWarehouseStock = $objDbRow->GetColumn($strAliasPrefix . 'local_warehouse_stock', 'Integer'); $objToReturn->intBadProductsWarehouseStock = $objDbRow->GetColumn($strAliasPrefix . 'bad_products_warehouse_stock', 'Integer'); $objToReturn->intSampleWarehouseStock = $objDbRow->GetColumn($strAliasPrefix . 'sample_warehouse_stock', 'Integer'); $objToReturn->intRepairWarehouseStock = $objDbRow->GetColumn($strAliasPrefix . 'repair_warehouse_stock', 'Integer'); // 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 = 'inventory_transaction__'; } // Check for InventoryLocation Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'inventory_location_id__inventory_location_id'))) { $objToReturn->objInventoryLocation = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventory_location_id__', $strExpandAsArrayNodes); } // Check for Transaction Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'transaction_id__transaction_id'))) { $objToReturn->objTransaction = Transaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transaction_id__', $strExpandAsArrayNodes); } // Check for SourceLocation Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'source_location_id__location_id'))) { $objToReturn->objSourceLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'source_location_id__', $strExpandAsArrayNodes); } // Check for DestinationLocation Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'destination_location_id__location_id'))) { $objToReturn->objDestinationLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'destination_location_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } return $objToReturn; }
/** * Instantiate a RoleModuleAuthorization from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this RoleModuleAuthorization::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return RoleModuleAuthorization */ 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 RoleModuleAuthorization object $objToReturn = new RoleModuleAuthorization(); $objToReturn->__blnRestored = true; $objToReturn->intRoleModuleAuthorizationId = $objDbRow->GetColumn($strAliasPrefix . 'role_module_authorization_id', 'Integer'); $objToReturn->intRoleModuleId = $objDbRow->GetColumn($strAliasPrefix . 'role_module_id', 'Integer'); $objToReturn->intAuthorizationId = $objDbRow->GetColumn($strAliasPrefix . 'authorization_id', 'Integer'); $objToReturn->intAuthorizationLevelId = $objDbRow->GetColumn($strAliasPrefix . 'authorization_level_id', 'Integer'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'role_module_authorization__'; } // Check for RoleModule Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'role_module_id__role_module_id'))) { $objToReturn->objRoleModule = RoleModule::InstantiateDbRow($objDbRow, $strAliasPrefix . 'role_module_id__', $strExpandAsArrayNodes); } // Check for Authorization Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'authorization_id__authorization_id'))) { $objToReturn->objAuthorization = Authorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorization_id__', $strExpandAsArrayNodes); } // Check for AuthorizationLevel Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'authorization_level_id__authorization_level_id'))) { $objToReturn->objAuthorizationLevel = AuthorizationLevel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorization_level_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } return $objToReturn; }
/** * Instantiate a AssetTransactionCheckout from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this AssetTransactionCheckout::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 AssetTransactionCheckout */ 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 AssetTransactionCheckout object $objToReturn = new AssetTransactionCheckout(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'asset_transaction_checkout_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_transaction_checkout_id'] : $strAliasPrefix . 'asset_transaction_checkout_id'; $objToReturn->intAssetTransactionCheckoutId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'asset_transaction_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_transaction_id'] : $strAliasPrefix . 'asset_transaction_id'; $objToReturn->intAssetTransactionId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'to_contact_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_contact_id'] : $strAliasPrefix . 'to_contact_id'; $objToReturn->intToContactId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'to_user_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_user_id'] : $strAliasPrefix . 'to_user_id'; $objToReturn->intToUserId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'due_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'due_date'] : $strAliasPrefix . 'due_date'; $objToReturn->dttDueDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'asset_transaction_checkout__'; } // Check for AssetTransaction Early Binding $strAlias = $strAliasPrefix . 'asset_transaction_id__asset_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAssetTransaction = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset_transaction_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ToContact Early Binding $strAlias = $strAliasPrefix . 'to_contact_id__contact_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objToContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_contact_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ToUser Early Binding $strAlias = $strAliasPrefix . 'to_user_id__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objToUser = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_user_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } return $objToReturn; }
/** * Instantiate a Location from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Location::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Location */ 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->intLocationId == $objDbRow->GetColumn($strAliasPrefix . 'location_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'location__'; } if (array_key_exists($strAliasPrefix . 'asset__asset_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'asset__asset_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAssetArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetArray[$intPreviousChildItemCount - 1]; $objChildItem = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAssetArray, $objChildItem); } } else { array_push($objPreviousItem->_objAssetArray, Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'assettransactionassource__asset_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransactionassource__asset_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAssetTransactionAsSourceArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionAsSourceArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAssetTransactionAsSourceArray, $objChildItem); } } else { array_push($objPreviousItem->_objAssetTransactionAsSourceArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'assettransactionasdestination__asset_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransactionasdestination__asset_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAssetTransactionAsDestinationArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetTransactionAsDestinationArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAssetTransactionAsDestinationArray, $objChildItem); } } else { array_push($objPreviousItem->_objAssetTransactionAsDestinationArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'auditscan__audit_scan_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'auditscan__audit_scan_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objAuditScanArray)) { $objPreviousChildItem = $objPreviousItem->_objAuditScanArray[$intPreviousChildItemCount - 1]; $objChildItem = AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objAuditScanArray, $objChildItem); } } else { array_push($objPreviousItem->_objAuditScanArray, AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'inventorylocation__inventory_location_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorylocation__inventory_location_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objInventoryLocationArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryLocationArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objInventoryLocationArray, $objChildItem); } } else { array_push($objPreviousItem->_objInventoryLocationArray, InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'inventorytransactionassource__inventory_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorytransactionassource__inventory_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objInventoryTransactionAsSourceArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryTransactionAsSourceArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objInventoryTransactionAsSourceArray, $objChildItem); } } else { array_push($objPreviousItem->_objInventoryTransactionAsSourceArray, InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'inventorytransactionasdestination__inventory_transaction_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorytransactionasdestination__inventory_transaction_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objInventoryTransactionAsDestinationArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryTransactionAsDestinationArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objInventoryTransactionAsDestinationArray, $objChildItem); } } else { array_push($objPreviousItem->_objInventoryTransactionAsDestinationArray, InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $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 == 'location__') { $strAliasPrefix = null; } } } // Create a new instance of the Location object $objToReturn = new Location(); $objToReturn->__blnRestored = true; $objToReturn->intLocationId = $objDbRow->GetColumn($strAliasPrefix . 'location_id', 'Integer'); $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasPrefix . 'short_description', 'VarChar'); $objToReturn->strLongDescription = $objDbRow->GetColumn($strAliasPrefix . 'long_description', 'Blob'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'location__'; } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for Asset Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'asset__asset_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'asset__asset_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAssetArray, Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAsset = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes); } } // Check for AssetTransactionAsSource Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransactionassource__asset_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'assettransactionassource__asset_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAssetTransactionAsSourceArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAssetTransactionAsSource = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes); } } // Check for AssetTransactionAsDestination Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'assettransactionasdestination__asset_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'assettransactionasdestination__asset_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAssetTransactionAsDestinationArray, AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAssetTransactionAsDestination = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes); } } // Check for AuditScan Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'auditscan__audit_scan_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'auditscan__audit_scan_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objAuditScanArray, AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes)); } else { $objToReturn->_objAuditScan = AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes); } } // Check for InventoryLocation Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorylocation__inventory_location_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'inventorylocation__inventory_location_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objInventoryLocationArray, InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes)); } else { $objToReturn->_objInventoryLocation = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes); } } // Check for InventoryTransactionAsSource Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorytransactionassource__inventory_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'inventorytransactionassource__inventory_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objInventoryTransactionAsSourceArray, InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes)); } else { $objToReturn->_objInventoryTransactionAsSource = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes); } } // Check for InventoryTransactionAsDestination Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'inventorytransactionasdestination__inventory_transaction_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'inventorytransactionasdestination__inventory_transaction_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objInventoryTransactionAsDestinationArray, InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $strExpandAsArrayNodes)); } else { $objToReturn->_objInventoryTransactionAsDestination = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a single UserAccount 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 UserAccount 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 UserAccount::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray); }
/** * Instantiate an array of UserAccounts from a Database Result * @param DatabaseResultBase $objDbResult * @return UserAccount[] */ 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 = UserAccount::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem); if ($objItem) { array_push($objToReturn, $objItem); $objLastRowItem = $objItem; } } } else { while ($objDbRow = $objDbResult->GetNextRow()) { array_push($objToReturn, UserAccount::InstantiateDbRow($objDbRow)); } } return $objToReturn; }
/** * Instantiate a Company from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Company::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 Company */ 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 . 'company_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intCompanyId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'company__'; } $strAlias = $strAliasPrefix . 'address__address_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->_objAddressArray)) { $objPreviousChildItem = $objPreviousItem->_objAddressArray[$intPreviousChildItemCount - 1]; $objChildItem = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'address__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objAddressArray[] = $objChildItem; } } else { $objPreviousItem->_objAddressArray[] = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'address__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'contact__contact_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->_objContactArray)) { $objPreviousChildItem = $objPreviousItem->_objContactArray[$intPreviousChildItemCount - 1]; $objChildItem = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objContactArray[] = $objChildItem; } } else { $objPreviousItem->_objContactArray[] = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'receiptasfrom__receipt_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->_objReceiptAsFromArray)) { $objPreviousChildItem = $objPreviousItem->_objReceiptAsFromArray[$intPreviousChildItemCount - 1]; $objChildItem = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasfrom__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objReceiptAsFromArray[] = $objChildItem; } } else { $objPreviousItem->_objReceiptAsFromArray[] = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasfrom__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'shipmentasfrom__shipment_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->_objShipmentAsFromArray)) { $objPreviousChildItem = $objPreviousItem->_objShipmentAsFromArray[$intPreviousChildItemCount - 1]; $objChildItem = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objShipmentAsFromArray[] = $objChildItem; } } else { $objPreviousItem->_objShipmentAsFromArray[] = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'shipmentasto__shipment_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->_objShipmentAsToArray)) { $objPreviousChildItem = $objPreviousItem->_objShipmentAsToArray[$intPreviousChildItemCount - 1]; $objChildItem = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objShipmentAsToArray[] = $objChildItem; } } else { $objPreviousItem->_objShipmentAsToArray[] = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $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 == 'company__') { $strAliasPrefix = null; } } } // Create a new instance of the Company object $objToReturn = new Company(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'company_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'company_id'] : $strAliasPrefix . 'company_id'; $objToReturn->intCompanyId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'address_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'address_id'] : $strAliasPrefix . 'address_id'; $objToReturn->intAddressId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'short_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'short_description'] : $strAliasPrefix . 'short_description'; $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'website', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'website'] : $strAliasPrefix . 'website'; $objToReturn->strWebsite = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'telephone', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'telephone'] : $strAliasPrefix . 'telephone'; $objToReturn->strTelephone = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'fax', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'fax'] : $strAliasPrefix . 'fax'; $objToReturn->strFax = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'email', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'email'] : $strAliasPrefix . 'email'; $objToReturn->strEmail = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'long_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'long_description'] : $strAliasPrefix . 'long_description'; $objToReturn->strLongDescription = $objDbRow->GetColumn($strAliasName, 'Blob'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'company__'; } // Check for Address Early Binding $strAlias = $strAliasPrefix . 'address_id__address_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAddress = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'address_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CompanyCustomFieldHelper Unique ReverseReference Binding $strAlias = $strAliasPrefix . 'companycustomfieldhelper__company_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($objDbRow->ColumnExists($strAliasName)) { if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCompanyCustomFieldHelper = CompanyCustomFieldHelper::InstantiateDbRow($objDbRow, $strAliasPrefix . 'companycustomfieldhelper__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objCompanyCustomFieldHelper = false; } } // Check for Address Virtual Binding $strAlias = $strAliasPrefix . 'address__address_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objAddressArray[] = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'address__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objAddress = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'address__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for Contact Virtual Binding $strAlias = $strAliasPrefix . 'contact__contact_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objContactArray[] = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for ReceiptAsFrom Virtual Binding $strAlias = $strAliasPrefix . 'receiptasfrom__receipt_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objReceiptAsFromArray[] = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasfrom__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objReceiptAsFrom = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasfrom__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for ShipmentAsFrom Virtual Binding $strAlias = $strAliasPrefix . 'shipmentasfrom__shipment_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objShipmentAsFromArray[] = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objShipmentAsFrom = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for ShipmentAsTo Virtual Binding $strAlias = $strAliasPrefix . 'shipmentasto__shipment_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objShipmentAsToArray[] = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objShipmentAsTo = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a InventoryLocation from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this InventoryLocation::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 InventoryLocation */ 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 . 'inventory_location_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intInventoryLocationId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'inventory_location__'; } $strAlias = $strAliasPrefix . 'inventorytransaction__inventory_transaction_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->_objInventoryTransactionArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryTransactionArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objInventoryTransactionArray[] = $objChildItem; } } else { $objPreviousItem->_objInventoryTransactionArray[] = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $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 == 'inventory_location__') { $strAliasPrefix = null; } } } // Create a new instance of the InventoryLocation object $objToReturn = new InventoryLocation(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'inventory_location_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'inventory_location_id'] : $strAliasPrefix . 'inventory_location_id'; $objToReturn->intInventoryLocationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'inventory_model_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'inventory_model_id'] : $strAliasPrefix . 'inventory_model_id'; $objToReturn->intInventoryModelId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'location_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'location_id'] : $strAliasPrefix . 'location_id'; $objToReturn->intLocationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'quantity', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'quantity'] : $strAliasPrefix . 'quantity'; $objToReturn->intQuantity = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'inventory_location__'; } // Check for InventoryModel Early Binding $strAlias = $strAliasPrefix . 'inventory_model_id__inventory_model_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objInventoryModel = InventoryModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventory_model_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for Location Early Binding $strAlias = $strAliasPrefix . 'location_id__location_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'location_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for InventoryTransaction Virtual Binding $strAlias = $strAliasPrefix . 'inventorytransaction__inventory_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objInventoryTransactionArray[] = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objInventoryTransaction = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a RoleModule from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this RoleModule::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return RoleModule */ 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->intRoleModuleId == $objDbRow->GetColumn($strAliasPrefix . 'role_module_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'role_module__'; } if (array_key_exists($strAliasPrefix . 'rolemoduleauthorization__role_module_authorization_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'rolemoduleauthorization__role_module_authorization_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objRoleModuleAuthorizationArray)) { $objPreviousChildItem = $objPreviousItem->_objRoleModuleAuthorizationArray[$intPreviousChildItemCount - 1]; $objChildItem = RoleModuleAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemoduleauthorization__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objRoleModuleAuthorizationArray, $objChildItem); } } else { array_push($objPreviousItem->_objRoleModuleAuthorizationArray, RoleModuleAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemoduleauthorization__', $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 == 'role_module__') { $strAliasPrefix = null; } } } // Create a new instance of the RoleModule object $objToReturn = new RoleModule(); $objToReturn->__blnRestored = true; $objToReturn->intRoleModuleId = $objDbRow->GetColumn($strAliasPrefix . 'role_module_id', 'Integer'); $objToReturn->intRoleId = $objDbRow->GetColumn($strAliasPrefix . 'role_id', 'Integer'); $objToReturn->intModuleId = $objDbRow->GetColumn($strAliasPrefix . 'module_id', 'Integer'); $objToReturn->blnAccessFlag = $objDbRow->GetColumn($strAliasPrefix . 'access_flag', 'Bit'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'role_module__'; } // Check for Role Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'role_id__role_id'))) { $objToReturn->objRole = Role::InstantiateDbRow($objDbRow, $strAliasPrefix . 'role_id__', $strExpandAsArrayNodes); } // Check for Module Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'module_id__module_id'))) { $objToReturn->objModule = Module::InstantiateDbRow($objDbRow, $strAliasPrefix . 'module_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for RoleModuleAuthorization Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'rolemoduleauthorization__role_module_authorization_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'rolemoduleauthorization__role_module_authorization_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objRoleModuleAuthorizationArray, RoleModuleAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemoduleauthorization__', $strExpandAsArrayNodes)); } else { $objToReturn->_objRoleModuleAuthorization = RoleModuleAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemoduleauthorization__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a Address from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Address::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Address */ 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->intAddressId == $objDbRow->GetColumn($strAliasPrefix . 'address_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'address__'; } if (array_key_exists($strAliasPrefix . 'company__company_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'company__company_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objCompanyArray)) { $objPreviousChildItem = $objPreviousItem->_objCompanyArray[$intPreviousChildItemCount - 1]; $objChildItem = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'company__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objCompanyArray, $objChildItem); } } else { array_push($objPreviousItem->_objCompanyArray, Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'company__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'contact__contact_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'contact__contact_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objContactArray)) { $objPreviousChildItem = $objPreviousItem->_objContactArray[$intPreviousChildItemCount - 1]; $objChildItem = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objContactArray, $objChildItem); } } else { array_push($objPreviousItem->_objContactArray, Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'receiptasto__receipt_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'receiptasto__receipt_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objReceiptAsToArray)) { $objPreviousChildItem = $objPreviousItem->_objReceiptAsToArray[$intPreviousChildItemCount - 1]; $objChildItem = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasto__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objReceiptAsToArray, $objChildItem); } } else { array_push($objPreviousItem->_objReceiptAsToArray, Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasto__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'shipmentasfrom__shipment_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'shipmentasfrom__shipment_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objShipmentAsFromArray)) { $objPreviousChildItem = $objPreviousItem->_objShipmentAsFromArray[$intPreviousChildItemCount - 1]; $objChildItem = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objShipmentAsFromArray, $objChildItem); } } else { array_push($objPreviousItem->_objShipmentAsFromArray, Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'shipmentasto__shipment_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'shipmentasto__shipment_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objShipmentAsToArray)) { $objPreviousChildItem = $objPreviousItem->_objShipmentAsToArray[$intPreviousChildItemCount - 1]; $objChildItem = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objShipmentAsToArray, $objChildItem); } } else { array_push($objPreviousItem->_objShipmentAsToArray, Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $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 == 'address__') { $strAliasPrefix = null; } } } // Create a new instance of the Address object $objToReturn = new Address(); $objToReturn->__blnRestored = true; $objToReturn->intAddressId = $objDbRow->GetColumn($strAliasPrefix . 'address_id', 'Integer'); $objToReturn->intCompanyId = $objDbRow->GetColumn($strAliasPrefix . 'company_id', 'Integer'); $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasPrefix . 'short_description', 'VarChar'); $objToReturn->intCountryId = $objDbRow->GetColumn($strAliasPrefix . 'country_id', 'Integer'); $objToReturn->strAddress1 = $objDbRow->GetColumn($strAliasPrefix . 'address_1', 'VarChar'); $objToReturn->strAddress2 = $objDbRow->GetColumn($strAliasPrefix . 'address_2', 'VarChar'); $objToReturn->strCity = $objDbRow->GetColumn($strAliasPrefix . 'city', 'VarChar'); $objToReturn->intStateProvinceId = $objDbRow->GetColumn($strAliasPrefix . 'state_province_id', 'Integer'); $objToReturn->strPostalCode = $objDbRow->GetColumn($strAliasPrefix . 'postal_code', 'VarChar'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'address__'; } // Check for Company Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'company_id__company_id'))) { $objToReturn->objCompany = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'company_id__', $strExpandAsArrayNodes); } // Check for Country Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'country_id__country_id'))) { $objToReturn->objCountry = Country::InstantiateDbRow($objDbRow, $strAliasPrefix . 'country_id__', $strExpandAsArrayNodes); } // Check for StateProvince Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'state_province_id__state_province_id'))) { $objToReturn->objStateProvince = StateProvince::InstantiateDbRow($objDbRow, $strAliasPrefix . 'state_province_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for Company Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'company__company_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'company__company_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objCompanyArray, Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'company__', $strExpandAsArrayNodes)); } else { $objToReturn->_objCompany = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'company__', $strExpandAsArrayNodes); } } // Check for Contact Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'contact__contact_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'contact__contact_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objContactArray, Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes)); } else { $objToReturn->_objContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contact__', $strExpandAsArrayNodes); } } // Check for ReceiptAsTo Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'receiptasto__receipt_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'receiptasto__receipt_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objReceiptAsToArray, Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasto__', $strExpandAsArrayNodes)); } else { $objToReturn->_objReceiptAsTo = Receipt::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptasto__', $strExpandAsArrayNodes); } } // Check for ShipmentAsFrom Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shipmentasfrom__shipment_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'shipmentasfrom__shipment_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objShipmentAsFromArray, Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes)); } else { $objToReturn->_objShipmentAsFrom = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasfrom__', $strExpandAsArrayNodes); } } // Check for ShipmentAsTo Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'shipmentasto__shipment_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'shipmentasto__shipment_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objShipmentAsToArray, Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $strExpandAsArrayNodes)); } else { $objToReturn->_objShipmentAsTo = Shipment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentasto__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a Receipt from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Receipt::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return Receipt */ 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 Receipt object $objToReturn = new Receipt(); $objToReturn->__blnRestored = true; $objToReturn->intReceiptId = $objDbRow->GetColumn($strAliasPrefix . 'receipt_id', 'Integer'); $objToReturn->intTransactionId = $objDbRow->GetColumn($strAliasPrefix . 'transaction_id', 'Integer'); $objToReturn->intFromCompanyId = $objDbRow->GetColumn($strAliasPrefix . 'from_company_id', 'Integer'); $objToReturn->intFromContactId = $objDbRow->GetColumn($strAliasPrefix . 'from_contact_id', 'Integer'); $objToReturn->intToContactId = $objDbRow->GetColumn($strAliasPrefix . 'to_contact_id', 'Integer'); $objToReturn->intToAddressId = $objDbRow->GetColumn($strAliasPrefix . 'to_address_id', 'Integer'); $objToReturn->strReceiptNumber = $objDbRow->GetColumn($strAliasPrefix . 'receipt_number', 'VarChar'); $objToReturn->dttDueDate = $objDbRow->GetColumn($strAliasPrefix . 'due_date', 'Date'); $objToReturn->dttReceiptDate = $objDbRow->GetColumn($strAliasPrefix . 'receipt_date', 'Date'); $objToReturn->blnReceivedFlag = $objDbRow->GetColumn($strAliasPrefix . 'received_flag', 'Bit'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'receipt__'; } // Check for Transaction Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'transaction_id__transaction_id'))) { $objToReturn->objTransaction = Transaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transaction_id__', $strExpandAsArrayNodes); } // Check for FromCompany Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'from_company_id__company_id'))) { $objToReturn->objFromCompany = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_company_id__', $strExpandAsArrayNodes); } // Check for FromContact Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'from_contact_id__contact_id'))) { $objToReturn->objFromContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_contact_id__', $strExpandAsArrayNodes); } // Check for ToContact Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'to_contact_id__contact_id'))) { $objToReturn->objToContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_contact_id__', $strExpandAsArrayNodes); } // Check for ToAddress Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'to_address_id__address_id'))) { $objToReturn->objToAddress = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_address_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } return $objToReturn; }
/** * Instantiate a AssetTransaction from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this AssetTransaction::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 AssetTransaction */ 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 . 'asset_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intAssetTransactionId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'asset_transaction__'; } $strAlias = $strAliasPrefix . 'childassettransaction__asset_transaction_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->_objChildAssetTransactionArray)) { $objPreviousChildItem = $objPreviousItem->_objChildAssetTransactionArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childassettransaction__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objChildAssetTransactionArray[] = $objChildItem; } } else { $objPreviousItem->_objChildAssetTransactionArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childassettransaction__', $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 == 'asset_transaction__') { $strAliasPrefix = null; } } } // Create a new instance of the AssetTransaction object $objToReturn = new AssetTransaction(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'asset_transaction_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_transaction_id'] : $strAliasPrefix . 'asset_transaction_id'; $objToReturn->intAssetTransactionId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'asset_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_id'] : $strAliasPrefix . 'asset_id'; $objToReturn->intAssetId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'transaction_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'transaction_id'] : $strAliasPrefix . 'transaction_id'; $objToReturn->intTransactionId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'parent_asset_transaction_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'parent_asset_transaction_id'] : $strAliasPrefix . 'parent_asset_transaction_id'; $objToReturn->intParentAssetTransactionId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'source_location_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'source_location_id'] : $strAliasPrefix . 'source_location_id'; $objToReturn->intSourceLocationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'destination_location_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'destination_location_id'] : $strAliasPrefix . 'destination_location_id'; $objToReturn->intDestinationLocationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'new_asset_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'new_asset_flag'] : $strAliasPrefix . 'new_asset_flag'; $objToReturn->blnNewAssetFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'new_asset_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'new_asset_id'] : $strAliasPrefix . 'new_asset_id'; $objToReturn->intNewAssetId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'schedule_receipt_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'schedule_receipt_flag'] : $strAliasPrefix . 'schedule_receipt_flag'; $objToReturn->blnScheduleReceiptFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'schedule_receipt_due_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'schedule_receipt_due_date'] : $strAliasPrefix . 'schedule_receipt_due_date'; $objToReturn->dttScheduleReceiptDueDate = $objDbRow->GetColumn($strAliasName, 'Date'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'asset_transaction__'; } // Check for Asset Early Binding $strAlias = $strAliasPrefix . 'asset_id__asset_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAsset = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for Transaction Early Binding $strAlias = $strAliasPrefix . 'transaction_id__transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objTransaction = Transaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transaction_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ParentAssetTransaction Early Binding $strAlias = $strAliasPrefix . 'parent_asset_transaction_id__asset_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objParentAssetTransaction = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'parent_asset_transaction_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for SourceLocation Early Binding $strAlias = $strAliasPrefix . 'source_location_id__location_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objSourceLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'source_location_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for DestinationLocation Early Binding $strAlias = $strAliasPrefix . 'destination_location_id__location_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objDestinationLocation = Location::InstantiateDbRow($objDbRow, $strAliasPrefix . 'destination_location_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for NewAsset Early Binding $strAlias = $strAliasPrefix . 'new_asset_id__asset_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objNewAsset = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'new_asset_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for AssetTransactionCheckout Unique ReverseReference Binding $strAlias = $strAliasPrefix . 'assettransactioncheckout__asset_transaction_checkout_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($objDbRow->ColumnExists($strAliasName)) { if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAssetTransactionCheckout = AssetTransactionCheckout::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactioncheckout__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objAssetTransactionCheckout = false; } } // Check for ChildAssetTransaction Virtual Binding $strAlias = $strAliasPrefix . 'childassettransaction__asset_transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objChildAssetTransactionArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childassettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objChildAssetTransaction = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childassettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a Manufacturer from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Manufacturer::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 Manufacturer */ 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 . 'manufacturer_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intManufacturerId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'manufacturer__'; } $strAlias = $strAliasPrefix . 'assetmodel__asset_model_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->_objAssetModelArray)) { $objPreviousChildItem = $objPreviousItem->_objAssetModelArray[$intPreviousChildItemCount - 1]; $objChildItem = AssetModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assetmodel__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objAssetModelArray[] = $objChildItem; } } else { $objPreviousItem->_objAssetModelArray[] = AssetModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assetmodel__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'inventorymodel__inventory_model_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->_objInventoryModelArray)) { $objPreviousChildItem = $objPreviousItem->_objInventoryModelArray[$intPreviousChildItemCount - 1]; $objChildItem = InventoryModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorymodel__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objInventoryModelArray[] = $objChildItem; } } else { $objPreviousItem->_objInventoryModelArray[] = InventoryModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorymodel__', $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 == 'manufacturer__') { $strAliasPrefix = null; } } } // Create a new instance of the Manufacturer object $objToReturn = new Manufacturer(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'manufacturer_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'manufacturer_id'] : $strAliasPrefix . 'manufacturer_id'; $objToReturn->intManufacturerId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'short_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'short_description'] : $strAliasPrefix . 'short_description'; $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'long_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'long_description'] : $strAliasPrefix . 'long_description'; $objToReturn->strLongDescription = $objDbRow->GetColumn($strAliasName, 'Blob'); $strAliasName = array_key_exists($strAliasPrefix . 'image_path', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'image_path'] : $strAliasPrefix . 'image_path'; $objToReturn->strImagePath = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'manufacturer__'; } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ManufacturerCustomFieldHelper Unique ReverseReference Binding $strAlias = $strAliasPrefix . 'manufacturercustomfieldhelper__manufacturer_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($objDbRow->ColumnExists($strAliasName)) { if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objManufacturerCustomFieldHelper = ManufacturerCustomFieldHelper::InstantiateDbRow($objDbRow, $strAliasPrefix . 'manufacturercustomfieldhelper__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objManufacturerCustomFieldHelper = false; } } // Check for AssetModel Virtual Binding $strAlias = $strAliasPrefix . 'assetmodel__asset_model_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objAssetModelArray[] = AssetModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assetmodel__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objAssetModel = AssetModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assetmodel__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for InventoryModel Virtual Binding $strAlias = $strAliasPrefix . 'inventorymodel__inventory_model_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objInventoryModelArray[] = InventoryModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorymodel__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objInventoryModel = InventoryModel::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorymodel__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a Shipment from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Shipment::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 Shipment */ 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 Shipment object $objToReturn = new Shipment(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'shipment_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'shipment_id'] : $strAliasPrefix . 'shipment_id'; $objToReturn->intShipmentId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'shipment_number', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'shipment_number'] : $strAliasPrefix . 'shipment_number'; $objToReturn->strShipmentNumber = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'transaction_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'transaction_id'] : $strAliasPrefix . 'transaction_id'; $objToReturn->intTransactionId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'from_company_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'from_company_id'] : $strAliasPrefix . 'from_company_id'; $objToReturn->intFromCompanyId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'from_contact_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'from_contact_id'] : $strAliasPrefix . 'from_contact_id'; $objToReturn->intFromContactId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'from_address_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'from_address_id'] : $strAliasPrefix . 'from_address_id'; $objToReturn->intFromAddressId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'to_company_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_company_id'] : $strAliasPrefix . 'to_company_id'; $objToReturn->intToCompanyId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'to_contact_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_contact_id'] : $strAliasPrefix . 'to_contact_id'; $objToReturn->intToContactId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'to_address_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_address_id'] : $strAliasPrefix . 'to_address_id'; $objToReturn->intToAddressId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'courier_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'courier_id'] : $strAliasPrefix . 'courier_id'; $objToReturn->intCourierId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'tracking_number', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'tracking_number'] : $strAliasPrefix . 'tracking_number'; $objToReturn->strTrackingNumber = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'ship_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'ship_date'] : $strAliasPrefix . 'ship_date'; $objToReturn->dttShipDate = $objDbRow->GetColumn($strAliasName, 'Date'); $strAliasName = array_key_exists($strAliasPrefix . 'shipped_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'shipped_flag'] : $strAliasPrefix . 'shipped_flag'; $objToReturn->blnShippedFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'shipment__'; } // Check for Transaction Early Binding $strAlias = $strAliasPrefix . 'transaction_id__transaction_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objTransaction = Transaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transaction_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for FromCompany Early Binding $strAlias = $strAliasPrefix . 'from_company_id__company_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objFromCompany = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_company_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for FromContact Early Binding $strAlias = $strAliasPrefix . 'from_contact_id__contact_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objFromContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_contact_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for FromAddress Early Binding $strAlias = $strAliasPrefix . 'from_address_id__address_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objFromAddress = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_address_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ToCompany Early Binding $strAlias = $strAliasPrefix . 'to_company_id__company_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objToCompany = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_company_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ToContact Early Binding $strAlias = $strAliasPrefix . 'to_contact_id__contact_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objToContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_contact_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ToAddress Early Binding $strAlias = $strAliasPrefix . 'to_address_id__address_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objToAddress = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_address_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for Courier Early Binding $strAlias = $strAliasPrefix . 'courier_id__courier_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCourier = Courier::InstantiateDbRow($objDbRow, $strAliasPrefix . 'courier_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ShipmentCustomFieldHelper Unique ReverseReference Binding $strAlias = $strAliasPrefix . 'shipmentcustomfieldhelper__shipment_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($objDbRow->ColumnExists($strAliasName)) { if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objShipmentCustomFieldHelper = ShipmentCustomFieldHelper::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipmentcustomfieldhelper__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist // Let's set to FALSE so that the object knows not to try and re-query again $objToReturn->objShipmentCustomFieldHelper = false; } } return $objToReturn; }
/** * Instantiate a Role from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this Role::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 Role */ 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 . 'role_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intRoleId == $objDbRow->GetColumn($strAliasName, 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'role__'; } $strAlias = $strAliasPrefix . 'roleentityqtypebuiltinauthorization__role_entity_built_in_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->_objRoleEntityQtypeBuiltInAuthorizationArray)) { $objPreviousChildItem = $objPreviousItem->_objRoleEntityQtypeBuiltInAuthorizationArray[$intPreviousChildItemCount - 1]; $objChildItem = RoleEntityQtypeBuiltInAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypebuiltinauthorization__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objRoleEntityQtypeBuiltInAuthorizationArray[] = $objChildItem; } } else { $objPreviousItem->_objRoleEntityQtypeBuiltInAuthorizationArray[] = RoleEntityQtypeBuiltInAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypebuiltinauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'roleentityqtypecustomfieldauthorization__role_entity_qtype_custom_field_authorization_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->_objRoleEntityQtypeCustomFieldAuthorizationArray)) { $objPreviousChildItem = $objPreviousItem->_objRoleEntityQtypeCustomFieldAuthorizationArray[$intPreviousChildItemCount - 1]; $objChildItem = RoleEntityQtypeCustomFieldAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypecustomfieldauthorization__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objRoleEntityQtypeCustomFieldAuthorizationArray[] = $objChildItem; } } else { $objPreviousItem->_objRoleEntityQtypeCustomFieldAuthorizationArray[] = RoleEntityQtypeCustomFieldAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypecustomfieldauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'rolemodule__role_module_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->_objRoleModuleArray)) { $objPreviousChildItem = $objPreviousItem->_objRoleModuleArray[$intPreviousChildItemCount - 1]; $objChildItem = RoleModule::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemodule__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objRoleModuleArray[] = $objChildItem; } } else { $objPreviousItem->_objRoleModuleArray[] = RoleModule::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemodule__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'roletransactiontypeauthorization__role_transaction_type_authorization_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->_objRoleTransactionTypeAuthorizationArray)) { $objPreviousChildItem = $objPreviousItem->_objRoleTransactionTypeAuthorizationArray[$intPreviousChildItemCount - 1]; $objChildItem = RoleTransactionTypeAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roletransactiontypeauthorization__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objRoleTransactionTypeAuthorizationArray[] = $objChildItem; } } else { $objPreviousItem->_objRoleTransactionTypeAuthorizationArray[] = RoleTransactionTypeAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roletransactiontypeauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } $blnExpandedViaArray = true; } $strAlias = $strAliasPrefix . 'useraccount__user_account_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->_objUserAccountArray)) { $objPreviousChildItem = $objPreviousItem->_objUserAccountArray[$intPreviousChildItemCount - 1]; $objChildItem = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'useraccount__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray); if ($objChildItem) { $objPreviousItem->_objUserAccountArray[] = $objChildItem; } } else { $objPreviousItem->_objUserAccountArray[] = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'useraccount__', $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 == 'role__') { $strAliasPrefix = null; } } } // Create a new instance of the Role object $objToReturn = new Role(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'role_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'role_id'] : $strAliasPrefix . 'role_id'; $objToReturn->intRoleId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'short_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'short_description'] : $strAliasPrefix . 'short_description'; $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'long_description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'long_description'] : $strAliasPrefix . 'long_description'; $objToReturn->strLongDescription = $objDbRow->GetColumn($strAliasName, 'Blob'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'role__'; } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for RoleEntityQtypeBuiltInAuthorization Virtual Binding $strAlias = $strAliasPrefix . 'roleentityqtypebuiltinauthorization__role_entity_built_in_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objRoleEntityQtypeBuiltInAuthorizationArray[] = RoleEntityQtypeBuiltInAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypebuiltinauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypebuiltinauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for RoleEntityQtypeCustomFieldAuthorization Virtual Binding $strAlias = $strAliasPrefix . 'roleentityqtypecustomfieldauthorization__role_entity_qtype_custom_field_authorization_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objRoleEntityQtypeCustomFieldAuthorizationArray[] = RoleEntityQtypeCustomFieldAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypecustomfieldauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objRoleEntityQtypeCustomFieldAuthorization = RoleEntityQtypeCustomFieldAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roleentityqtypecustomfieldauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for RoleModule Virtual Binding $strAlias = $strAliasPrefix . 'rolemodule__role_module_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objRoleModuleArray[] = RoleModule::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemodule__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objRoleModule = RoleModule::InstantiateDbRow($objDbRow, $strAliasPrefix . 'rolemodule__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for RoleTransactionTypeAuthorization Virtual Binding $strAlias = $strAliasPrefix . 'roletransactiontypeauthorization__role_transaction_type_authorization_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objRoleTransactionTypeAuthorizationArray[] = RoleTransactionTypeAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roletransactiontypeauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'roletransactiontypeauthorization__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } // Check for UserAccount Virtual Binding $strAlias = $strAliasPrefix . 'useraccount__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) { $objToReturn->_objUserAccountArray[] = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'useraccount__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } else { $objToReturn->_objUserAccount = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'useraccount__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } } return $objToReturn; }
/** * Instantiate a CustomField from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this CustomField::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return CustomField */ 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->intCustomFieldId == $objDbRow->GetColumn($strAliasPrefix . 'custom_field_id', 'Integer')) { // We are. Now, prepare to check for ExpandAsArray clauses $blnExpandedViaArray = false; if (!$strAliasPrefix) { $strAliasPrefix = 'custom_field__'; } if (array_key_exists($strAliasPrefix . 'customfieldvalue__custom_field_value_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'customfieldvalue__custom_field_value_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objCustomFieldValueArray)) { $objPreviousChildItem = $objPreviousItem->_objCustomFieldValueArray[$intPreviousChildItemCount - 1]; $objChildItem = CustomFieldValue::InstantiateDbRow($objDbRow, $strAliasPrefix . 'customfieldvalue__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objCustomFieldValueArray, $objChildItem); } } else { array_push($objPreviousItem->_objCustomFieldValueArray, CustomFieldValue::InstantiateDbRow($objDbRow, $strAliasPrefix . 'customfieldvalue__', $strExpandAsArrayNodes)); } $blnExpandedViaArray = true; } if (array_key_exists($strAliasPrefix . 'entityqtypecustomfield__entity_qtype_custom_field_id', $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasPrefix . 'entityqtypecustomfield__entity_qtype_custom_field_id'))) { if ($intPreviousChildItemCount = count($objPreviousItem->_objEntityQtypeCustomFieldArray)) { $objPreviousChildItem = $objPreviousItem->_objEntityQtypeCustomFieldArray[$intPreviousChildItemCount - 1]; $objChildItem = EntityQtypeCustomField::InstantiateDbRow($objDbRow, $strAliasPrefix . 'entityqtypecustomfield__', $strExpandAsArrayNodes, $objPreviousChildItem); if ($objChildItem) { array_push($objPreviousItem->_objEntityQtypeCustomFieldArray, $objChildItem); } } else { array_push($objPreviousItem->_objEntityQtypeCustomFieldArray, EntityQtypeCustomField::InstantiateDbRow($objDbRow, $strAliasPrefix . 'entityqtypecustomfield__', $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 == 'custom_field__') { $strAliasPrefix = null; } } } // Create a new instance of the CustomField object $objToReturn = new CustomField(); $objToReturn->__blnRestored = true; $objToReturn->intCustomFieldId = $objDbRow->GetColumn($strAliasPrefix . 'custom_field_id', 'Integer'); $objToReturn->intCustomFieldQtypeId = $objDbRow->GetColumn($strAliasPrefix . 'custom_field_qtype_id', 'Integer'); $objToReturn->intDefaultCustomFieldValueId = $objDbRow->GetColumn($strAliasPrefix . 'default_custom_field_value_id', 'Integer'); $objToReturn->strShortDescription = $objDbRow->GetColumn($strAliasPrefix . 'short_description', 'VarChar'); $objToReturn->blnActiveFlag = $objDbRow->GetColumn($strAliasPrefix . 'active_flag', 'Bit'); $objToReturn->blnRequiredFlag = $objDbRow->GetColumn($strAliasPrefix . 'required_flag', 'Bit'); $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasPrefix . 'created_by', 'Integer'); $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasPrefix . 'creation_date', 'DateTime'); $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasPrefix . 'modified_by', 'Integer'); $objToReturn->strModifiedDate = $objDbRow->GetColumn($strAliasPrefix . 'modified_date', '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 = 'custom_field__'; } // Check for DefaultCustomFieldValue Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'default_custom_field_value_id__custom_field_value_id'))) { $objToReturn->objDefaultCustomFieldValue = CustomFieldValue::InstantiateDbRow($objDbRow, $strAliasPrefix . 'default_custom_field_value_id__', $strExpandAsArrayNodes); } // Check for CreatedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'created_by__user_account_id'))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes); } // Check for ModifiedByObject Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'modified_by__user_account_id'))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes); } // Check for CustomFieldValue Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'customfieldvalue__custom_field_value_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'customfieldvalue__custom_field_value_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objCustomFieldValueArray, CustomFieldValue::InstantiateDbRow($objDbRow, $strAliasPrefix . 'customfieldvalue__', $strExpandAsArrayNodes)); } else { $objToReturn->_objCustomFieldValue = CustomFieldValue::InstantiateDbRow($objDbRow, $strAliasPrefix . 'customfieldvalue__', $strExpandAsArrayNodes); } } // Check for EntityQtypeCustomField Virtual Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'entityqtypecustomfield__entity_qtype_custom_field_id'))) { if ($strExpandAsArrayNodes && array_key_exists($strAliasPrefix . 'entityqtypecustomfield__entity_qtype_custom_field_id', $strExpandAsArrayNodes)) { array_push($objToReturn->_objEntityQtypeCustomFieldArray, EntityQtypeCustomField::InstantiateDbRow($objDbRow, $strAliasPrefix . 'entityqtypecustomfield__', $strExpandAsArrayNodes)); } else { $objToReturn->_objEntityQtypeCustomField = EntityQtypeCustomField::InstantiateDbRow($objDbRow, $strAliasPrefix . 'entityqtypecustomfield__', $strExpandAsArrayNodes); } } return $objToReturn; }
/** * Instantiate a RoleEntityQtypeBuiltInAuthorization from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this RoleEntityQtypeBuiltInAuthorization::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 RoleEntityQtypeBuiltInAuthorization */ 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 RoleEntityQtypeBuiltInAuthorization object $objToReturn = new RoleEntityQtypeBuiltInAuthorization(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'role_entity_built_in_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'role_entity_built_in_id'] : $strAliasPrefix . 'role_entity_built_in_id'; $objToReturn->intRoleEntityBuiltInId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'role_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'role_id'] : $strAliasPrefix . 'role_id'; $objToReturn->intRoleId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'entity_qtype_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'entity_qtype_id'] : $strAliasPrefix . 'entity_qtype_id'; $objToReturn->intEntityQtypeId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'authorization_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'authorization_id'] : $strAliasPrefix . 'authorization_id'; $objToReturn->intAuthorizationId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'authorized_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'authorized_flag'] : $strAliasPrefix . 'authorized_flag'; $objToReturn->blnAuthorizedFlag = $objDbRow->GetColumn($strAliasName, 'Bit'); $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by'; $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date'; $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by'; $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date'; $objToReturn->strModifiedDate = $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 = 'role_entity_qtype_built_in_authorization__'; } // Check for Role Early Binding $strAlias = $strAliasPrefix . 'role_id__role_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objRole = Role::InstantiateDbRow($objDbRow, $strAliasPrefix . 'role_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for Authorization Early Binding $strAlias = $strAliasPrefix . 'authorization_id__authorization_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objAuthorization = Authorization::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorization_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for CreatedByObject Early Binding $strAlias = $strAliasPrefix . 'created_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } // Check for ModifiedByObject Early Binding $strAlias = $strAliasPrefix . 'modified_by__user_account_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } return $objToReturn; }
/** * Instantiate a NotificationUserAccount from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this NotificationUserAccount::InstantiateDbRow in order to perform * early binding on referenced objects. * @param DatabaseRowBase $objDbRow * @param string $strAliasPrefix * @return NotificationUserAccount */ 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 NotificationUserAccount object $objToReturn = new NotificationUserAccount(); $objToReturn->__blnRestored = true; $objToReturn->intNotificationUserAccountId = $objDbRow->GetColumn($strAliasPrefix . 'notification_user_account_id', 'Integer'); $objToReturn->intUserAccountId = $objDbRow->GetColumn($strAliasPrefix . 'user_account_id', 'Integer'); $objToReturn->intNotificationId = $objDbRow->GetColumn($strAliasPrefix . 'notification_id', 'Integer'); $objToReturn->strLevel = $objDbRow->GetColumn($strAliasPrefix . 'level', '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 = 'notification_user_account__'; } // Check for UserAccount Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'user_account_id__user_account_id'))) { $objToReturn->objUserAccount = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'user_account_id__', $strExpandAsArrayNodes); } // Check for Notification Early Binding if (!is_null($objDbRow->GetColumn($strAliasPrefix . 'notification_id__notification_id'))) { $objToReturn->objNotification = Notification::InstantiateDbRow($objDbRow, $strAliasPrefix . 'notification_id__', $strExpandAsArrayNodes); } return $objToReturn; }