/**
  * 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 QDatabaseRowBase $objDbRow
  * @param string $strAliasPrefix
  * @param string $strExpandAsArrayNodes
  * @param QBaseClass $objPreviousItem
  * @param string[] $strColumnAliasArray
  * @return Location
  */
 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 . 'location_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intLocationId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
         // We are.  Now, prepare to check for ExpandAsArray clauses
         $blnExpandedViaArray = false;
         if (!$strAliasPrefix) {
             $strAliasPrefix = 'location__';
         }
         $strAlias = $strAliasPrefix . 'asset__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->_objAssetArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objAssetArray[$intPreviousChildItemCount - 1];
                 $objChildItem = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objAssetArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objAssetArray[] = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $blnExpandedViaArray = true;
         }
         $strAlias = $strAliasPrefix . 'assettransactionassource__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->_objAssetTransactionAsSourceArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objAssetTransactionAsSourceArray[$intPreviousChildItemCount - 1];
                 $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objAssetTransactionAsSourceArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objAssetTransactionAsSourceArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $blnExpandedViaArray = true;
         }
         $strAlias = $strAliasPrefix . 'assettransactionasdestination__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->_objAssetTransactionAsDestinationArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objAssetTransactionAsDestinationArray[$intPreviousChildItemCount - 1];
                 $objChildItem = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objAssetTransactionAsDestinationArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objAssetTransactionAsDestinationArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $blnExpandedViaArray = true;
         }
         $strAlias = $strAliasPrefix . 'auditscan__audit_scan_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->_objAuditScanArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objAuditScanArray[$intPreviousChildItemCount - 1];
                 $objChildItem = AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objAuditScanArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objAuditScanArray[] = AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $blnExpandedViaArray = true;
         }
         $strAlias = $strAliasPrefix . 'inventorylocation__inventory_location_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->_objInventoryLocationArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objInventoryLocationArray[$intPreviousChildItemCount - 1];
                 $objChildItem = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objInventoryLocationArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objInventoryLocationArray[] = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $blnExpandedViaArray = true;
         }
         $strAlias = $strAliasPrefix . 'inventorytransactionassource__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->_objInventoryTransactionAsSourceArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objInventoryTransactionAsSourceArray[$intPreviousChildItemCount - 1];
                 $objChildItem = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objInventoryTransactionAsSourceArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objInventoryTransactionAsSourceArray[] = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
             }
             $blnExpandedViaArray = true;
         }
         $strAlias = $strAliasPrefix . 'inventorytransactionasdestination__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->_objInventoryTransactionAsDestinationArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objInventoryTransactionAsDestinationArray[$intPreviousChildItemCount - 1];
                 $objChildItem = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objInventoryTransactionAsDestinationArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objInventoryTransactionAsDestinationArray[] = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $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 == 'location__') {
                 $strAliasPrefix = null;
             }
         }
     }
     // Create a new instance of the Location object
     $objToReturn = new Location();
     $objToReturn->__blnRestored = true;
     $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 . '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 . 'enabled_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'enabled_flag'] : $strAliasPrefix . 'enabled_flag';
     $objToReturn->blnEnabledFlag = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAliasName = array_key_exists($strAliasPrefix . 'asset_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'asset_flag'] : $strAliasPrefix . 'asset_flag';
     $objToReturn->blnAssetFlag = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAliasName = array_key_exists($strAliasPrefix . 'inventory_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'inventory_flag'] : $strAliasPrefix . 'inventory_flag';
     $objToReturn->blnInventoryFlag = $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 = 'location__';
     }
     // 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 Asset Virtual Binding
     $strAlias = $strAliasPrefix . 'asset__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->_objAssetArray[] = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objAsset = Asset::InstantiateDbRow($objDbRow, $strAliasPrefix . 'asset__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for AssetTransactionAsSource Virtual Binding
     $strAlias = $strAliasPrefix . 'assettransactionassource__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->_objAssetTransactionAsSourceArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objAssetTransactionAsSource = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionassource__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for AssetTransactionAsDestination Virtual Binding
     $strAlias = $strAliasPrefix . 'assettransactionasdestination__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->_objAssetTransactionAsDestinationArray[] = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objAssetTransactionAsDestination = AssetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'assettransactionasdestination__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for AuditScan Virtual Binding
     $strAlias = $strAliasPrefix . 'auditscan__audit_scan_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objAuditScanArray[] = AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objAuditScan = AuditScan::InstantiateDbRow($objDbRow, $strAliasPrefix . 'auditscan__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for InventoryLocation Virtual Binding
     $strAlias = $strAliasPrefix . 'inventorylocation__inventory_location_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objInventoryLocationArray[] = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objInventoryLocation = InventoryLocation::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorylocation__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for InventoryTransactionAsSource Virtual Binding
     $strAlias = $strAliasPrefix . 'inventorytransactionassource__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->_objInventoryTransactionAsSourceArray[] = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objInventoryTransactionAsSource = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionassource__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for InventoryTransactionAsDestination Virtual Binding
     $strAlias = $strAliasPrefix . 'inventorytransactionasdestination__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->_objInventoryTransactionAsDestinationArray[] = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objInventoryTransactionAsDestination = InventoryTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'inventorytransactionasdestination__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }
 /**
  * Instantiate a single AuditScan 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 AuditScan 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 AuditScan::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }
Beispiel #3
0
 /**
  * Instantiate a Audit from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this Audit::InstantiateDbRow in order to perform
  * early binding on referenced objects.
  * @param DatabaseRowBase $objDbRow
  * @param string $strAliasPrefix
  * @return Audit
  */
 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->intAuditId == $objDbRow->GetColumn($strAliasPrefix . 'audit_id', 'Integer')) {
         // We are.  Now, prepare to check for ExpandAsArray clauses
         $blnExpandedViaArray = false;
         if (!$strAliasPrefix) {
             $strAliasPrefix = 'audit__';
         }
         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;
         }
         // Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
         if ($blnExpandedViaArray) {
             return false;
         } else {
             if ($strAliasPrefix == 'audit__') {
                 $strAliasPrefix = null;
             }
         }
     }
     // Create a new instance of the Audit object
     $objToReturn = new Audit();
     $objToReturn->__blnRestored = true;
     $objToReturn->intAuditId = $objDbRow->GetColumn($strAliasPrefix . 'audit_id', 'Integer');
     $objToReturn->intEntityQtypeId = $objDbRow->GetColumn($strAliasPrefix . 'entity_qtype_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 = 'audit__';
     }
     // 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 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);
         }
     }
     return $objToReturn;
 }
Beispiel #4
0
 /**
  * Instantiate an array of AuditScans from a Database Result
  * @param DatabaseResultBase $objDbResult
  * @return AuditScan[]
  */
 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 = AuditScan::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem);
             if ($objItem) {
                 array_push($objToReturn, $objItem);
                 $objLastRowItem = $objItem;
             }
         }
     } else {
         while ($objDbRow = $objDbResult->GetNextRow()) {
             array_push($objToReturn, AuditScan::InstantiateDbRow($objDbRow));
         }
     }
     return $objToReturn;
 }