Пример #1
0
 /**
  * Instantiate a PublicLogin from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this PublicLogin::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 PublicLogin
  */
 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 PublicLogin object
     $objToReturn = new PublicLogin();
     $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 . 'person_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'person_id'] : $strAliasPrefix . 'person_id';
     $objToReturn->intPersonId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'active_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'active_flag'] : $strAliasPrefix . 'active_flag';
     $objToReturn->blnActiveFlag = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAliasName = array_key_exists($strAliasPrefix . 'username', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'username'] : $strAliasPrefix . 'username';
     $objToReturn->strUsername = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'password', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'password'] : $strAliasPrefix . 'password';
     $objToReturn->strPassword = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'lost_password_question', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'lost_password_question'] : $strAliasPrefix . 'lost_password_question';
     $objToReturn->strLostPasswordQuestion = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'lost_password_answer', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'lost_password_answer'] : $strAliasPrefix . 'lost_password_answer';
     $objToReturn->strLostPasswordAnswer = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'temporary_password_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'temporary_password_flag'] : $strAliasPrefix . 'temporary_password_flag';
     $objToReturn->blnTemporaryPasswordFlag = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAliasName = array_key_exists($strAliasPrefix . 'date_registered', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'date_registered'] : $strAliasPrefix . 'date_registered';
     $objToReturn->dttDateRegistered = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAliasName = array_key_exists($strAliasPrefix . 'date_last_login', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'date_last_login'] : $strAliasPrefix . 'date_last_login';
     $objToReturn->dttDateLastLogin = $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 = 'public_login__';
     }
     // Check for Person Early Binding
     $strAlias = $strAliasPrefix . 'person_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objPerson = Person::InstantiateDbRow($objDbRow, $strAliasPrefix . 'person_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for ProvisionalPublicLogin Unique ReverseReference Binding
     $strAlias = $strAliasPrefix . 'provisionalpubliclogin__public_login_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($objDbRow->ColumnExists($strAliasName)) {
         if (!is_null($objDbRow->GetColumn($strAliasName))) {
             $objToReturn->objProvisionalPublicLogin = ProvisionalPublicLogin::InstantiateDbRow($objDbRow, $strAliasPrefix . 'provisionalpubliclogin__', $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->objProvisionalPublicLogin = false;
         }
     }
     return $objToReturn;
 }
Пример #2
0
 /**
  * Instantiate a single ProvisionalPublicLogin 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 ProvisionalPublicLogin 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 ProvisionalPublicLogin::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }