/**
  * Instantiate a NarroSuggestionVote from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this NarroSuggestionVote::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 NarroSuggestionVote
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array())
 {
     // If blank row, return null
     if (!$objDbRow) {
         return null;
     }
     // Create a new instance of the NarroSuggestionVote object
     $objToReturn = new NarroSuggestionVote();
     $objToReturn->__blnRestored = true;
     $strAlias = $strAliasPrefix . 'suggestion_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intSuggestionId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $objToReturn->__intSuggestionId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'context_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intContextId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $objToReturn->__intContextId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'user_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intUserId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $objToReturn->__intUserId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'vote_value';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intVoteValue = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'created';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->dttCreated = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAlias = $strAliasPrefix . 'modified';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->dttModified = $objDbRow->GetColumn($strAliasName, 'DateTime');
     if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objToReturn->SuggestionId != $objPreviousItem->SuggestionId) {
                 continue;
             }
             if ($objToReturn->ContextId != $objPreviousItem->ContextId) {
                 continue;
             }
             if ($objToReturn->UserId != $objPreviousItem->UserId) {
                 continue;
             }
             // complete match - all primary key columns are the same
             return null;
         }
     }
     // Instantiate Virtual Attributes
     $strVirtualPrefix = $strAliasPrefix . '__';
     $strVirtualPrefixLength = strlen($strVirtualPrefix);
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         if (strncmp($strColumnName, $strVirtualPrefix, $strVirtualPrefixLength) == 0) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'narro_suggestion_vote__';
     }
     // Check for Suggestion Early Binding
     $strAlias = $strAliasPrefix . 'suggestion_id__suggestion_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objSuggestion = NarroSuggestion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'suggestion_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for Context Early Binding
     $strAlias = $strAliasPrefix . 'context_id__context_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objContext = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'context_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for User Early Binding
     $strAlias = $strAliasPrefix . 'user_id__user_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objUser = NarroUser::InstantiateDbRow($objDbRow, $strAliasPrefix . 'user_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     return $objToReturn;
 }
Example #2
0
 /**
  * Instantiate a single NarroContext 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 NarroContext 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 NarroContext::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }
Example #3
0
 /**
  * Instantiate a NarroText from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this NarroText::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 NarroText
  */
 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 . 'text_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && is_array($arrPreviousItems) && count($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objPreviousItem->intTextId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
                 // We are.  Now, prepare to check for ExpandAsArray clauses
                 $blnExpandedViaArray = false;
                 if (!$strAliasPrefix) {
                     $strAliasPrefix = 'narro_text__';
                 }
                 // Expanding reverse references: NarroContextAsText
                 $strAlias = $strAliasPrefix . 'narrocontextastext__context_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroContextAsTextArray) {
                         $objPreviousItem->_objNarroContextAsTextArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroContextAsTextArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroContextAsTextArray;
                         $objChildItem = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextastext__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroContextAsTextArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroContextAsTextArray[] = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroSuggestionAsText
                 $strAlias = $strAliasPrefix . 'narrosuggestionastext__suggestion_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroSuggestionAsTextArray) {
                         $objPreviousItem->_objNarroSuggestionAsTextArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroSuggestionAsTextArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroSuggestionAsTextArray;
                         $objChildItem = NarroSuggestion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrosuggestionastext__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroSuggestionAsTextArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroSuggestionAsTextArray[] = NarroSuggestion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrosuggestionastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroTextCommentAsText
                 $strAlias = $strAliasPrefix . 'narrotextcommentastext__text_comment_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroTextCommentAsTextArray) {
                         $objPreviousItem->_objNarroTextCommentAsTextArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroTextCommentAsTextArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroTextCommentAsTextArray;
                         $objChildItem = NarroTextComment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrotextcommentastext__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroTextCommentAsTextArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroTextCommentAsTextArray[] = NarroTextComment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrotextcommentastext__', $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 == 'narro_text__') {
                         $strAliasPrefix = null;
                     }
                 }
             }
         }
     }
     // Create a new instance of the NarroText object
     $objToReturn = new NarroText();
     $objToReturn->__blnRestored = true;
     $strAlias = $strAliasPrefix . 'text_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intTextId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'text_value';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strTextValue = $objDbRow->GetColumn($strAliasName, 'Blob');
     $strAlias = $strAliasPrefix . 'text_value_md5';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strTextValueMd5 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAlias = $strAliasPrefix . 'text_char_count';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intTextCharCount = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'text_word_count';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intTextWordCount = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'has_comments';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->blnHasComments = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAlias = $strAliasPrefix . 'created';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->dttCreated = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAlias = $strAliasPrefix . 'modified';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->dttModified = $objDbRow->GetColumn($strAliasName, 'DateTime');
     if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objToReturn->TextId != $objPreviousItem->TextId) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroContextAsTextArray);
             $cnt = count($objToReturn->_objNarroContextAsTextArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroContextAsTextArray, $objToReturn->_objNarroContextAsTextArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroSuggestionAsTextArray);
             $cnt = count($objToReturn->_objNarroSuggestionAsTextArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroSuggestionAsTextArray, $objToReturn->_objNarroSuggestionAsTextArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroTextCommentAsTextArray);
             $cnt = count($objToReturn->_objNarroTextCommentAsTextArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroTextCommentAsTextArray, $objToReturn->_objNarroTextCommentAsTextArray)) {
                 continue;
             }
             // complete match - all primary key columns are the same
             return null;
         }
     }
     // Instantiate Virtual Attributes
     $strVirtualPrefix = $strAliasPrefix . '__';
     $strVirtualPrefixLength = strlen($strVirtualPrefix);
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         if (strncmp($strColumnName, $strVirtualPrefix, $strVirtualPrefixLength) == 0) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'narro_text__';
     }
     // Check for NarroContextAsText Virtual Binding
     $strAlias = $strAliasPrefix . 'narrocontextastext__context_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroContextAsTextArray) {
         $objToReturn->_objNarroContextAsTextArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroContextAsTextArray[] = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroContextAsText = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroSuggestionAsText Virtual Binding
     $strAlias = $strAliasPrefix . 'narrosuggestionastext__suggestion_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroSuggestionAsTextArray) {
         $objToReturn->_objNarroSuggestionAsTextArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroSuggestionAsTextArray[] = NarroSuggestion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrosuggestionastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroSuggestionAsText = NarroSuggestion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrosuggestionastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroTextCommentAsText Virtual Binding
     $strAlias = $strAliasPrefix . 'narrotextcommentastext__text_comment_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroTextCommentAsTextArray) {
         $objToReturn->_objNarroTextCommentAsTextArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroTextCommentAsTextArray[] = NarroTextComment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrotextcommentastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroTextCommentAsText = NarroTextComment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrotextcommentastext__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }
Example #4
0
 /**
  * Instantiate a NarroFile from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this NarroFile::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 NarroFile
  */
 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 . 'file_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && is_array($arrPreviousItems) && count($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objPreviousItem->intFileId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
                 // We are.  Now, prepare to check for ExpandAsArray clauses
                 $blnExpandedViaArray = false;
                 if (!$strAliasPrefix) {
                     $strAliasPrefix = 'narro_file__';
                 }
                 // Expanding reverse references: NarroContextAsFile
                 $strAlias = $strAliasPrefix . 'narrocontextasfile__context_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroContextAsFileArray) {
                         $objPreviousItem->_objNarroContextAsFileArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroContextAsFileArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroContextAsFileArray;
                         $objChildItem = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasfile__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroContextAsFileArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroContextAsFileArray[] = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasfile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: ChildNarroFile
                 $strAlias = $strAliasPrefix . 'childnarrofile__file_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objChildNarroFileArray) {
                         $objPreviousItem->_objChildNarroFileArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objChildNarroFileArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objChildNarroFileArray;
                         $objChildItem = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childnarrofile__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objChildNarroFileArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objChildNarroFileArray[] = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childnarrofile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroFileProgressAsFile
                 $strAlias = $strAliasPrefix . 'narrofileprogressasfile__file_progress_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroFileProgressAsFileArray) {
                         $objPreviousItem->_objNarroFileProgressAsFileArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroFileProgressAsFileArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroFileProgressAsFileArray;
                         $objChildItem = NarroFileProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileprogressasfile__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroFileProgressAsFileArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroFileProgressAsFileArray[] = NarroFileProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileprogressasfile__', $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 == 'narro_file__') {
                         $strAliasPrefix = null;
                     }
                 }
             }
         }
     }
     // Create a new instance of the NarroFile object
     $objToReturn = new NarroFile();
     $objToReturn->__blnRestored = true;
     $strAlias = $strAliasPrefix . 'file_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intFileId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'file_name';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strFileName = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAlias = $strAliasPrefix . 'file_path';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strFilePath = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAlias = $strAliasPrefix . 'file_md5';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strFileMd5 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAlias = $strAliasPrefix . 'parent_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intParentId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'type_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'project_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intProjectId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'active';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->blnActive = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAlias = $strAliasPrefix . 'created';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->dttCreated = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAlias = $strAliasPrefix . 'modified';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->dttModified = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAlias = $strAliasPrefix . 'header';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strHeader = $objDbRow->GetColumn($strAliasName, 'Blob');
     if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objToReturn->FileId != $objPreviousItem->FileId) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroContextAsFileArray);
             $cnt = count($objToReturn->_objNarroContextAsFileArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroContextAsFileArray, $objToReturn->_objNarroContextAsFileArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objChildNarroFileArray);
             $cnt = count($objToReturn->_objChildNarroFileArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objChildNarroFileArray, $objToReturn->_objChildNarroFileArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroFileProgressAsFileArray);
             $cnt = count($objToReturn->_objNarroFileProgressAsFileArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroFileProgressAsFileArray, $objToReturn->_objNarroFileProgressAsFileArray)) {
                 continue;
             }
             // complete match - all primary key columns are the same
             return null;
         }
     }
     // Instantiate Virtual Attributes
     $strVirtualPrefix = $strAliasPrefix . '__';
     $strVirtualPrefixLength = strlen($strVirtualPrefix);
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         if (strncmp($strColumnName, $strVirtualPrefix, $strVirtualPrefixLength) == 0) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'narro_file__';
     }
     // Check for Parent Early Binding
     $strAlias = $strAliasPrefix . 'parent_id__file_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objParent = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'parent_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for Project Early Binding
     $strAlias = $strAliasPrefix . 'project_id__project_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objProject = NarroProject::InstantiateDbRow($objDbRow, $strAliasPrefix . 'project_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for NarroContextAsFile Virtual Binding
     $strAlias = $strAliasPrefix . 'narrocontextasfile__context_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroContextAsFileArray) {
         $objToReturn->_objNarroContextAsFileArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroContextAsFileArray[] = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasfile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroContextAsFile = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasfile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for ChildNarroFile Virtual Binding
     $strAlias = $strAliasPrefix . 'childnarrofile__file_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objChildNarroFileArray) {
         $objToReturn->_objChildNarroFileArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objChildNarroFileArray[] = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childnarrofile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objChildNarroFile = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'childnarrofile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroFileProgressAsFile Virtual Binding
     $strAlias = $strAliasPrefix . 'narrofileprogressasfile__file_progress_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroFileProgressAsFileArray) {
         $objToReturn->_objNarroFileProgressAsFileArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroFileProgressAsFileArray[] = NarroFileProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileprogressasfile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroFileProgressAsFile = NarroFileProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileprogressasfile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }
Example #5
0
 /**
  * Instantiate a NarroProject from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this NarroProject::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 NarroProject
  */
 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 . 'project_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && is_array($arrPreviousItems) && count($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objPreviousItem->intProjectId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
                 // We are.  Now, prepare to check for ExpandAsArray clauses
                 $blnExpandedViaArray = false;
                 if (!$strAliasPrefix) {
                     $strAliasPrefix = 'narro_project__';
                 }
                 // Expanding reverse references: NarroContextAsProject
                 $strAlias = $strAliasPrefix . 'narrocontextasproject__context_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroContextAsProjectArray) {
                         $objPreviousItem->_objNarroContextAsProjectArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroContextAsProjectArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroContextAsProjectArray;
                         $objChildItem = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasproject__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroContextAsProjectArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroContextAsProjectArray[] = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroFileAsProject
                 $strAlias = $strAliasPrefix . 'narrofileasproject__file_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroFileAsProjectArray) {
                         $objPreviousItem->_objNarroFileAsProjectArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroFileAsProjectArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroFileAsProjectArray;
                         $objChildItem = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileasproject__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroFileAsProjectArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroFileAsProjectArray[] = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroLogAsProject
                 $strAlias = $strAliasPrefix . 'narrologasproject__log_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroLogAsProjectArray) {
                         $objPreviousItem->_objNarroLogAsProjectArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroLogAsProjectArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroLogAsProjectArray;
                         $objChildItem = NarroLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrologasproject__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroLogAsProjectArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroLogAsProjectArray[] = NarroLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrologasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroProjectProgressAsProject
                 $strAlias = $strAliasPrefix . 'narroprojectprogressasproject__project_progress_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroProjectProgressAsProjectArray) {
                         $objPreviousItem->_objNarroProjectProgressAsProjectArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroProjectProgressAsProjectArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroProjectProgressAsProjectArray;
                         $objChildItem = NarroProjectProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narroprojectprogressasproject__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroProjectProgressAsProjectArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroProjectProgressAsProjectArray[] = NarroProjectProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narroprojectprogressasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
                     }
                     $blnExpandedViaArray = true;
                 }
                 // Expanding reverse references: NarroUserRoleAsProject
                 $strAlias = $strAliasPrefix . 'narrouserroleasproject__user_role_id';
                 $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
                 if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
                     if (null === $objPreviousItem->_objNarroUserRoleAsProjectArray) {
                         $objPreviousItem->_objNarroUserRoleAsProjectArray = array();
                     }
                     if ($intPreviousChildItemCount = count($objPreviousItem->_objNarroUserRoleAsProjectArray)) {
                         $objPreviousChildItems = $objPreviousItem->_objNarroUserRoleAsProjectArray;
                         $objChildItem = NarroUserRole::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrouserroleasproject__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
                         if ($objChildItem) {
                             $objPreviousItem->_objNarroUserRoleAsProjectArray[] = $objChildItem;
                         }
                     } else {
                         $objPreviousItem->_objNarroUserRoleAsProjectArray[] = NarroUserRole::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrouserroleasproject__', $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 == 'narro_project__') {
                         $strAliasPrefix = null;
                     }
                 }
             }
         }
     }
     // Create a new instance of the NarroProject object
     $objToReturn = new NarroProject();
     $objToReturn->__blnRestored = true;
     $strAlias = $strAliasPrefix . 'project_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intProjectId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'project_category_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intProjectCategoryId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'project_name';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strProjectName = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAlias = $strAliasPrefix . 'project_type';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intProjectType = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAlias = $strAliasPrefix . 'project_description';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strProjectDescription = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAlias = $strAliasPrefix . 'data';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->strData = $objDbRow->GetColumn($strAliasName, 'Blob');
     $strAlias = $strAliasPrefix . 'active';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $objToReturn->intActive = $objDbRow->GetColumn($strAliasName, 'Integer');
     if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objToReturn->ProjectId != $objPreviousItem->ProjectId) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroContextAsProjectArray);
             $cnt = count($objToReturn->_objNarroContextAsProjectArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroContextAsProjectArray, $objToReturn->_objNarroContextAsProjectArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroFileAsProjectArray);
             $cnt = count($objToReturn->_objNarroFileAsProjectArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroFileAsProjectArray, $objToReturn->_objNarroFileAsProjectArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroLogAsProjectArray);
             $cnt = count($objToReturn->_objNarroLogAsProjectArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroLogAsProjectArray, $objToReturn->_objNarroLogAsProjectArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroProjectProgressAsProjectArray);
             $cnt = count($objToReturn->_objNarroProjectProgressAsProjectArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroProjectProgressAsProjectArray, $objToReturn->_objNarroProjectProgressAsProjectArray)) {
                 continue;
             }
             $prevCnt = count($objPreviousItem->_objNarroUserRoleAsProjectArray);
             $cnt = count($objToReturn->_objNarroUserRoleAsProjectArray);
             if ($prevCnt != $cnt) {
                 continue;
             }
             if ($prevCnt == 0 || $cnt == 0 || !array_diff($objPreviousItem->_objNarroUserRoleAsProjectArray, $objToReturn->_objNarroUserRoleAsProjectArray)) {
                 continue;
             }
             // complete match - all primary key columns are the same
             return null;
         }
     }
     // Instantiate Virtual Attributes
     $strVirtualPrefix = $strAliasPrefix . '__';
     $strVirtualPrefixLength = strlen($strVirtualPrefix);
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         if (strncmp($strColumnName, $strVirtualPrefix, $strVirtualPrefixLength) == 0) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'narro_project__';
     }
     // Check for ProjectCategory Early Binding
     $strAlias = $strAliasPrefix . 'project_category_id__project_category_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objProjectCategory = NarroProjectCategory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'project_category_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for NarroContextAsProject Virtual Binding
     $strAlias = $strAliasPrefix . 'narrocontextasproject__context_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroContextAsProjectArray) {
         $objToReturn->_objNarroContextAsProjectArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroContextAsProjectArray[] = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroContextAsProject = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrocontextasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroFileAsProject Virtual Binding
     $strAlias = $strAliasPrefix . 'narrofileasproject__file_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroFileAsProjectArray) {
         $objToReturn->_objNarroFileAsProjectArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroFileAsProjectArray[] = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroFileAsProject = NarroFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrofileasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroLogAsProject Virtual Binding
     $strAlias = $strAliasPrefix . 'narrologasproject__log_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroLogAsProjectArray) {
         $objToReturn->_objNarroLogAsProjectArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroLogAsProjectArray[] = NarroLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrologasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroLogAsProject = NarroLog::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrologasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroProjectProgressAsProject Virtual Binding
     $strAlias = $strAliasPrefix . 'narroprojectprogressasproject__project_progress_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroProjectProgressAsProjectArray) {
         $objToReturn->_objNarroProjectProgressAsProjectArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroProjectProgressAsProjectArray[] = NarroProjectProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narroprojectprogressasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroProjectProgressAsProject = NarroProjectProgress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narroprojectprogressasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     // Check for NarroUserRoleAsProject Virtual Binding
     $strAlias = $strAliasPrefix . 'narrouserroleasproject__user_role_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     $blnExpanded = $strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes);
     if ($blnExpanded && null === $objToReturn->_objNarroUserRoleAsProjectArray) {
         $objToReturn->_objNarroUserRoleAsProjectArray = array();
     }
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($blnExpanded) {
             $objToReturn->_objNarroUserRoleAsProjectArray[] = NarroUserRole::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrouserroleasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objNarroUserRoleAsProject = NarroUserRole::InstantiateDbRow($objDbRow, $strAliasPrefix . 'narrouserroleasproject__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }
 /**
  * Instantiate a NarroContextComment from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this NarroContextComment::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 NarroContextComment
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array())
 {
     // If blank row, return null
     if (!$objDbRow) {
         return null;
     }
     // Create a new instance of the NarroContextComment object
     $objToReturn = new NarroContextComment();
     $objToReturn->__blnRestored = true;
     $strAliasName = array_key_exists($strAliasPrefix . 'comment_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'comment_id'] : $strAliasPrefix . 'comment_id';
     $objToReturn->intCommentId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'context_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'context_id'] : $strAliasPrefix . 'context_id';
     $objToReturn->intContextId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'created', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created'] : $strAliasPrefix . 'created';
     $objToReturn->dttCreated = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAliasName = array_key_exists($strAliasPrefix . 'modified', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified'] : $strAliasPrefix . 'modified';
     $objToReturn->dttModified = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAliasName = array_key_exists($strAliasPrefix . 'comment_text', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'comment_text'] : $strAliasPrefix . 'comment_text';
     $objToReturn->strCommentText = $objDbRow->GetColumn($strAliasName, 'Blob');
     $strAliasName = array_key_exists($strAliasPrefix . 'comment_text_md5', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'comment_text_md5'] : $strAliasPrefix . 'comment_text_md5';
     $objToReturn->strCommentTextMd5 = $objDbRow->GetColumn($strAliasName, 'VarChar');
     if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
         foreach ($arrPreviousItems as $objPreviousItem) {
             if ($objToReturn->CommentId != $objPreviousItem->CommentId) {
                 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 = 'narro_context_comment__';
     }
     // Check for Context Early Binding
     $strAlias = $strAliasPrefix . 'context_id__context_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objContext = NarroContext::InstantiateDbRow($objDbRow, $strAliasPrefix . 'context_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     return $objToReturn;
 }