コード例 #1
0
 /**
  * Instantiate a Receipt from a Database Row.
  * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  * is calling this Receipt::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 Receipt
  */
 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 Receipt object
     $objToReturn = new Receipt();
     $objToReturn->__blnRestored = true;
     $strAliasName = array_key_exists($strAliasPrefix . 'receipt_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'receipt_id'] : $strAliasPrefix . 'receipt_id';
     $objToReturn->intReceiptId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'transaction_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'transaction_id'] : $strAliasPrefix . 'transaction_id';
     $objToReturn->intTransactionId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'from_company_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'from_company_id'] : $strAliasPrefix . 'from_company_id';
     $objToReturn->intFromCompanyId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'from_contact_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'from_contact_id'] : $strAliasPrefix . 'from_contact_id';
     $objToReturn->intFromContactId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'to_contact_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_contact_id'] : $strAliasPrefix . 'to_contact_id';
     $objToReturn->intToContactId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'to_address_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'to_address_id'] : $strAliasPrefix . 'to_address_id';
     $objToReturn->intToAddressId = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'receipt_number', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'receipt_number'] : $strAliasPrefix . 'receipt_number';
     $objToReturn->strReceiptNumber = $objDbRow->GetColumn($strAliasName, 'VarChar');
     $strAliasName = array_key_exists($strAliasPrefix . 'due_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'due_date'] : $strAliasPrefix . 'due_date';
     $objToReturn->dttDueDate = $objDbRow->GetColumn($strAliasName, 'Date');
     $strAliasName = array_key_exists($strAliasPrefix . 'receipt_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'receipt_date'] : $strAliasPrefix . 'receipt_date';
     $objToReturn->dttReceiptDate = $objDbRow->GetColumn($strAliasName, 'Date');
     $strAliasName = array_key_exists($strAliasPrefix . 'received_flag', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'received_flag'] : $strAliasPrefix . 'received_flag';
     $objToReturn->blnReceivedFlag = $objDbRow->GetColumn($strAliasName, 'Bit');
     $strAliasName = array_key_exists($strAliasPrefix . 'created_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'created_by'] : $strAliasPrefix . 'created_by';
     $objToReturn->intCreatedBy = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date';
     $objToReturn->dttCreationDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
     $strAliasName = array_key_exists($strAliasPrefix . 'modified_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_by'] : $strAliasPrefix . 'modified_by';
     $objToReturn->intModifiedBy = $objDbRow->GetColumn($strAliasName, 'Integer');
     $strAliasName = array_key_exists($strAliasPrefix . 'modified_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'modified_date'] : $strAliasPrefix . 'modified_date';
     $objToReturn->strModifiedDate = $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 = 'receipt__';
     }
     // Check for Transaction Early Binding
     $strAlias = $strAliasPrefix . 'transaction_id__transaction_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objTransaction = Transaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transaction_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for FromCompany Early Binding
     $strAlias = $strAliasPrefix . 'from_company_id__company_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objFromCompany = Company::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_company_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for FromContact Early Binding
     $strAlias = $strAliasPrefix . 'from_contact_id__contact_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objFromContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'from_contact_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for ToContact Early Binding
     $strAlias = $strAliasPrefix . 'to_contact_id__contact_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objToContact = Contact::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_contact_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for ToAddress Early Binding
     $strAlias = $strAliasPrefix . 'to_address_id__address_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objToAddress = Address::InstantiateDbRow($objDbRow, $strAliasPrefix . 'to_address_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for CreatedByObject Early Binding
     $strAlias = $strAliasPrefix . 'created_by__user_account_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objCreatedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'created_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for ModifiedByObject Early Binding
     $strAlias = $strAliasPrefix . 'modified_by__user_account_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if (!is_null($objDbRow->GetColumn($strAliasName))) {
         $objToReturn->objModifiedByObject = UserAccount::InstantiateDbRow($objDbRow, $strAliasPrefix . 'modified_by__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
     }
     // Check for ReceiptCustomFieldHelper Unique ReverseReference Binding
     $strAlias = $strAliasPrefix . 'receiptcustomfieldhelper__receipt_id';
     $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
     if ($objDbRow->ColumnExists($strAliasName)) {
         if (!is_null($objDbRow->GetColumn($strAliasName))) {
             $objToReturn->objReceiptCustomFieldHelper = ReceiptCustomFieldHelper::InstantiateDbRow($objDbRow, $strAliasPrefix . 'receiptcustomfieldhelper__', $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->objReceiptCustomFieldHelper = false;
         }
     }
     return $objToReturn;
 }
コード例 #2
0
 /**
  * Instantiate a single ReceiptCustomFieldHelper 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 ReceiptCustomFieldHelper 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 ReceiptCustomFieldHelper::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
 }