/**
  * Instantiate a Word from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this Word::InstantiateDbRow in order to perform
  * early binding on referenced objects.
  * @param DatabaseRowBase $objDbRow
  * @param string $strAliasPrefix
  * @param string $strExpandAsArrayNodes
  * @param QBaseClass $arrPreviousItem
  * @param string[] $strColumnAliasArray
  * @return Word
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = 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 . 'word_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && is_array($arrPreviousItems) && count($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objPreviousItem->intWordId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
                 // We are.  Now, prepare to check for ExpandAsArray clauses
                 $blnExpandedViaArray = false;
                 if (!$strAliasPrefix) {
                     $strAliasPrefix = 'submit_word_word__';
                 }
                 // Expanding reverse references: SentLogAsWord
                 $strAlias = $strAliasPrefix . 'sentlogasword__word_sent_log_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->_objSentLogAsWordArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objSentLogAsWordArray;
                         $objChildItem = SentLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'sentlogasword__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objSentLogAsWordArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objSentLogAsWordArray[] = SentLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'sentlogasword__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: WordStatusLogAsWord
                 $strAlias = $strAliasPrefix . 'wordstatuslogasword__word_status_log_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->_objWordStatusLogAsWordArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objWordStatusLogAsWordArray;
                         $objChildItem = WordStatusLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wordstatuslogasword__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objWordStatusLogAsWordArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objWordStatusLogAsWordArray[] = WordStatusLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wordstatuslogasword__', $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 == 'submit_word_word__') {
                         $strAliasPrefix = null;
                     }
                 }
             }
         }
     }
     // Create a new instance of the Word object
     $objToReturn = new Word();
     $objToReturn->__blnRestored = true;
     $strAliasName = array_key_exists($strAliasPrefix . 'word_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'word_id'] : $strAliasPrefix . 'word_id';
     $objToReturn->intWordId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'word', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'word'] : $strAliasPrefix . 'word';
     $objToReturn->strWord = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'status_type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status_type_id'] : $strAliasPrefix . 'status_type_id';
     $objToReturn->intStatusTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'proposal_count', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'proposal_count'] : $strAliasPrefix . 'proposal_count';
     $objToReturn->intProposalCount = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'last_sent', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'last_sent'] : $strAliasPrefix . 'last_sent';
     $objToReturn->dttLastSent = $objDbRow->GetColumn($strAliasName, 'DateTime');
     if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objToReturn->WordId != $objPreviousItem->WordId) {
                 continue;
             }
             if (array_diff($objPreviousItem->_objSentLogAsWordArray, $objToReturn->_objSentLogAsWordArray) != null) {
                 continue;
             }
             if (array_diff($objPreviousItem->_objWordStatusLogAsWordArray, $objToReturn->_objWordStatusLogAsWordArray) != null) {
                 continue;
             }
             // complete match - all primary key columns are the same
             return null;
         }
     }
     // 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 = 'submit_word_word__';
     }
     // Check for SentLogAsWord Virtual Binding
     $strAlias = $strAliasPrefix . 'sentlogasword__word_sent_log_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objSentLogAsWordArray[] = SentLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'sentlogasword__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objSentLogAsWord = SentLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'sentlogasword__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for WordStatusLogAsWord Virtual Binding
     $strAlias = $strAliasPrefix . 'wordstatuslogasword__word_status_log_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objWordStatusLogAsWordArray[] = WordStatusLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wordstatuslogasword__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objWordStatusLogAsWord = WordStatusLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wordstatuslogasword__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }
 /**
  * Instantiate an array of SentLogs from a Database Result
  * @param DatabaseResultBase $objDbResult
  * @param string $strExpandAsArrayNodes
  * @param string[] $strColumnAliasArray
  * @return SentLog[]
  */
 public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null)
 {
     $objToReturn = array();
     if (!$strColumnAliasArray) {
         $strColumnAliasArray = array();
     }
     // If blank resultset, then return empty array
     if (!$objDbResult) {
         return $objToReturn;
     }
     // Load up the return array with each row
     if ($strExpandAsArrayNodes) {
         $objToReturn = array();
         while ($objDbRow = $objDbResult->GetNextRow()) {
             $objItem = SentLog::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray);
             if ($objItem) {
                 $objToReturn[] = $objItem;
             }
         }
     } else {
         while ($objDbRow = $objDbResult->GetNextRow()) {
             $objToReturn[] = SentLog::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }