コード例 #1
0
ファイル: PaymentPeriodGen.class.php プロジェクト: alcf/chms
 /**
  * Instantiate a PaymentPeriod from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this PaymentPeriod::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 PaymentPeriod
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = 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 . 'id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
         // We are.  Now, prepare to check for ExpandAsArray clauses
         $blnExpandedViaArray = false;
         if (!$strAliasPrefix) {
             $strAliasPrefix = 'payment_period__';
         }
         $strAlias = $strAliasPrefix . 'recurringpayments__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->_objRecurringPaymentsArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objRecurringPaymentsArray[$intPreviousChildItemCount - 1];
                 $objChildItem = RecurringPayments::InstantiateDbRow($objDbRow, $strAliasPrefix . 'recurringpayments__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objRecurringPaymentsArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objRecurringPaymentsArray[] = RecurringPayments::InstantiateDbRow($objDbRow, $strAliasPrefix . 'recurringpayments__', $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 == 'payment_period__') {
                 $strAliasPrefix = null;
             }
         }
     }
     // Create a new instance of the PaymentPeriod object
     $objToReturn = new PaymentPeriod();
     $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 . 'name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'name'] : $strAliasPrefix . 'name';
     $objToReturn->strName = $objDbRow->GetColumn($strAliasName, 'VarChar');
     // 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 = 'payment_period__';
     }
     // Check for RecurringPayments Virtual Binding
     $strAlias = $strAliasPrefix . 'recurringpayments__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objRecurringPaymentsArray[] = RecurringPayments::InstantiateDbRow($objDbRow, $strAliasPrefix . 'recurringpayments__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objRecurringPayments = RecurringPayments::InstantiateDbRow($objDbRow, $strAliasPrefix . 'recurringpayments__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }
コード例 #2
0
 /**
  * Instantiate a single RecurringPayments 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 RecurringPayments 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 RecurringPayments::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }
コード例 #3
0
ファイル: OnlineDonationGen.class.php プロジェクト: alcf/chms
 /**
  * Instantiate a OnlineDonation from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this OnlineDonation::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 OnlineDonation
  */
 public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = 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 . 'id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
         // We are.  Now, prepare to check for ExpandAsArray clauses
         $blnExpandedViaArray = false;
         if (!$strAliasPrefix) {
             $strAliasPrefix = 'online_donation__';
         }
         $strAlias = $strAliasPrefix . 'onlinedonationlineitem__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->_objOnlineDonationLineItemArray)) {
                 $objPreviousChildItem = $objPreviousItem->_objOnlineDonationLineItemArray[$intPreviousChildItemCount - 1];
                 $objChildItem = OnlineDonationLineItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'onlinedonationlineitem__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
                 if ($objChildItem) {
                     $objPreviousItem->_objOnlineDonationLineItemArray[] = $objChildItem;
                 }
             } else {
                 $objPreviousItem->_objOnlineDonationLineItemArray[] = OnlineDonationLineItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'onlinedonationlineitem__', $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 == 'online_donation__') {
                 $strAliasPrefix = null;
             }
         }
     }
     // Create a new instance of the OnlineDonation object
     $objToReturn = new OnlineDonation();
     $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 . 'confirmation_email', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'confirmation_email'] : $strAliasPrefix . 'confirmation_email';
     $objToReturn->strConfirmationEmail = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'amount', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'amount'] : $strAliasPrefix . 'amount';
     $objToReturn->fltAmount = $objDbRow->GetColumn($strAliasName, 'Float');
     $strAliasName = array_key_exists($strAliasPrefix . 'credit_card_payment_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'credit_card_payment_id'] : $strAliasPrefix . 'credit_card_payment_id';
     $objToReturn->intCreditCardPaymentId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'is_recurring_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'is_recurring_flag'] : $strAliasPrefix . 'is_recurring_flag';
     $objToReturn->blnIsRecurringFlag = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAliasName = array_key_exists($strAliasPrefix . 'status', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status'] : $strAliasPrefix . 'status';
     $objToReturn->intStatus = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'recurring_payment_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'recurring_payment_id'] : $strAliasPrefix . 'recurring_payment_id';
     $objToReturn->intRecurringPaymentId = $objDbRow->GetColumn($strAliasName, 'Integer');
     // 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 = 'online_donation__';
     }
     // 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 CreditCardPayment Early Binding
     $strAlias = $strAliasPrefix . 'credit_card_payment_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objCreditCardPayment = CreditCardPayment::InstantiateDbRow($objDbRow, $strAliasPrefix . 'credit_card_payment_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for RecurringPayment Early Binding
     $strAlias = $strAliasPrefix . 'recurring_payment_id__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objRecurringPayment = RecurringPayments::InstantiateDbRow($objDbRow, $strAliasPrefix . 'recurring_payment_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for OnlineDonationLineItem Virtual Binding
     $strAlias = $strAliasPrefix . 'onlinedonationlineitem__id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         if ($strExpandAsArrayNodes && array_key_exists($strAlias, $strExpandAsArrayNodes)) {
             $objToReturn->_objOnlineDonationLineItemArray[] = OnlineDonationLineItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'onlinedonationlineitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         } else {
             $objToReturn->_objOnlineDonationLineItem = OnlineDonationLineItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'onlinedonationlineitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
         }
     }
     return $objToReturn;
 }