/**
  * Instantiate a single WikiPage 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 WikiPage 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 WikiPage::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }
 /**
  * Instantiate a WikiVersion from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this WikiVersion::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 WikiVersion
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array())
 {
     // If blank row, return null
     if (!$objDbRow) {
         return null;
     }
     // Create a new instance of the WikiVersion object
     $objToReturn = new WikiVersion();
     $objToReturn->__blnRestored = true;
     $strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
     $objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'wiki_item_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'wiki_item_id'] : $strAliasPrefix . 'wiki_item_id';
     $objToReturn->intWikiItemId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'version_number', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'version_number'] : $strAliasPrefix . 'version_number';
     $objToReturn->intVersionNumber = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'name'] : $strAliasPrefix . 'name';
     $objToReturn->strName = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'posted_by_person_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'posted_by_person_id'] : $strAliasPrefix . 'posted_by_person_id';
     $objToReturn->intPostedByPersonId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'post_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'post_date'] : $strAliasPrefix . 'post_date';
     $objToReturn->dttPostDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
     // Instantiate Virtual Attributes
     foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
         $strVirtualPrefix = $strAliasPrefix . '__';
         $strVirtualPrefixLength = strlen($strVirtualPrefix);
         if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix) {
             $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
         }
     }
     // Prepare to Check for Early/Virtual Binding
     if (!$strAliasPrefix) {
         $strAliasPrefix = 'wiki_version__';
     }
     // Check for WikiItem Early Binding
     $strAlias = $strAliasPrefix . 'wiki_item_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objWikiItem = WikiItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wiki_item_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for PostedByPerson Early Binding
     $strAlias = $strAliasPrefix . 'posted_by_person_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objPostedByPerson = Person::InstantiateDbRow($objDbRow, $strAliasPrefix . 'posted_by_person_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for WikiFile Unique ReverseReference Binding
     $strAlias = $strAliasPrefix . 'wikifile__wiki_version_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($objDbRow->ColumnExists($strAliasName)) {
         if (!is_null($objDbRow->GetColumn($strAliasName))) {
             $objToReturn->objWikiFile = WikiFile::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wikifile__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist
             // Let's set to FALSE so that the object knows not to try and re-query again
             $objToReturn->objWikiFile = false;
         }
     }
     // Check for WikiImage Unique ReverseReference Binding
     $strAlias = $strAliasPrefix . 'wikiimage__wiki_version_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($objDbRow->ColumnExists($strAliasName)) {
         if (!is_null($objDbRow->GetColumn($strAliasName))) {
             $objToReturn->objWikiImage = WikiImage::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wikiimage__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist
             // Let's set to FALSE so that the object knows not to try and re-query again
             $objToReturn->objWikiImage = false;
         }
     }
     // Check for WikiItemAsCurrent Unique ReverseReference Binding
     $strAlias = $strAliasPrefix . 'wikiitemascurrent__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($objDbRow->ColumnExists($strAliasName)) {
         if (!is_null($objDbRow->GetColumn($strAliasName))) {
             $objToReturn->objWikiItemAsCurrent = WikiItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wikiitemascurrent__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist
             // Let's set to FALSE so that the object knows not to try and re-query again
             $objToReturn->objWikiItemAsCurrent = false;
         }
     }
     // Check for WikiPage Unique ReverseReference Binding
     $strAlias = $strAliasPrefix . 'wikipage__wiki_version_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($objDbRow->ColumnExists($strAliasName)) {
         if (!is_null($objDbRow->GetColumn($strAliasName))) {
             $objToReturn->objWikiPage = WikiPage::InstantiateDbRow($objDbRow, $strAliasPrefix . 'wikipage__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             // We ATTEMPTED to do an Early Bind but the Object Doesn't Exist
             // Let's set to FALSE so that the object knows not to try and re-query again
             $objToReturn->objWikiPage = false;
         }
     }
     return $objToReturn;
 }
 /**
  * Instantiate an array of WikiPages from a Database Result
  * @param DatabaseResultBase $objDbResult
  * @param string $strExpandAsArrayNodes
  * @param string[] $strColumnAliasArray
  * @return WikiPage[]
  */
 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) {
         $objLastRowItem = null;
         while ($objDbRow = $objDbResult->GetNextRow()) {
             $objItem = WikiPage::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
             if ($objItem) {
                 $objToReturn[] = $objItem;
                 $objLastRowItem = $objItem;
             }
         }
     } else {
         while ($objDbRow = $objDbResult->GetNextRow()) {
             $objToReturn[] = WikiPage::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }