/** * Instantiate a WordStatusLog from a Database Row. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow * is calling this WordStatusLog::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 WordStatusLog */ 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 WordStatusLog object $objToReturn = new WordStatusLog(); $objToReturn->__blnRestored = true; $strAliasName = array_key_exists($strAliasPrefix . 'word_status_log_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'word_status_log_id'] : $strAliasPrefix . 'word_status_log_id'; $objToReturn->intWordStatusLogId = $objDbRow->GetColumn($strAliasName, 'Integer'); $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 . 'status_type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status_type_id'] : $strAliasPrefix . 'status_type_id'; $objToReturn->intStatusTypeId = $objDbRow->GetColumn($strAliasName, 'Integer'); $strAliasName = array_key_exists($strAliasPrefix . 'changed_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'changed_by'] : $strAliasPrefix . 'changed_by'; $objToReturn->strChangedBy = $objDbRow->GetColumn($strAliasName, 'VarChar'); $strAliasName = array_key_exists($strAliasPrefix . 'changed_at', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'changed_at'] : $strAliasPrefix . 'changed_at'; $objToReturn->dttChangedAt = $objDbRow->GetColumn($strAliasName, 'DateTime'); if (isset($arrPreviousItems) && is_array($arrPreviousItems)) { foreach ($arrPreviousItems as $objPreviousItem) { if ($objToReturn->WordStatusLogId != $objPreviousItem->WordStatusLogId) { 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_status_log__'; } // Check for Word Early Binding $strAlias = $strAliasPrefix . 'word_id__word_id'; $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias; if (!is_null($objDbRow->GetColumn($strAliasName))) { $objToReturn->objWord = Word::InstantiateDbRow($objDbRow, $strAliasPrefix . 'word_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray); } return $objToReturn; }
/** * Instantiate an array of Words from a Database Result * @param DatabaseResultBase $objDbResult * @param string $strExpandAsArrayNodes * @param string[] $strColumnAliasArray * @return Word[] */ 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 = Word::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray); if ($objItem) { $objToReturn[] = $objItem; } } } else { while ($objDbRow = $objDbResult->GetNextRow()) { $objToReturn[] = Word::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray); } } return $objToReturn; }