當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SplSubject::getCurrentTransactionResult方法代碼示例

本文整理匯總了PHP中SplSubject::getCurrentTransactionResult方法的典型用法代碼示例。如果您正苦於以下問題:PHP SplSubject::getCurrentTransactionResult方法的具體用法?PHP SplSubject::getCurrentTransactionResult怎麽用?PHP SplSubject::getCurrentTransactionResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SplSubject的用法示例。


在下文中一共展示了SplSubject::getCurrentTransactionResult方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * (PHP 5 &gt;= 5.1.0)<br/>
  * Receive update from subject
  * @link http://php.net/manual/en/splobserver.update.php
  * @param SplSubject $subject <p>
  * The <b>SplSubject</b> notifying the observer of an update.
  * </p>
  * @return void
  */
 public function update(SplSubject $subject)
 {
     $position = $subject->getCurrentLine();
     $params = $subject->getCurrentTransactionParameters();
     $result = $subject->getCurrentTransactionResult();
     if ($position == 0) {
         $this->knownResultHeaders = array_keys($result);
         $this->headers = array_unique(array_merge(array_keys($params), $this->knownResultHeaders));
         sort($this->headers);
         // Write headers
         fputcsv($this->file, $this->headers, $subject->getDelimiter(), $subject->getEnclosure());
     }
     $newLine = array_merge($params, $result);
     $this->inMemoryImage[] = $newLine;
     // Search for new header keys
     $newKeys = array_diff(array_keys($result), $this->knownResultHeaders);
     // Search for missing header keys
     $missingKeys = array_diff($this->knownResultHeaders, array_keys($result));
     // Set to empty missing keys values so fputcsv will generate empty columns
     foreach ($missingKeys as $missingKey) {
         $newLine[$missingKey] = '';
     }
     // Rewrite full memory image and file
     if ($newKeys) {
         rewind($this->file);
         // Add new headers
         $this->headers = array_unique(array_merge($this->headers, $newKeys));
         $this->knownResultHeaders = array_unique(array_merge($this->knownResultHeaders, $newKeys));
         // Rewrite headers
         sort($this->headers);
         fputcsv($this->file, $this->headers, $subject->getDelimiter(), $subject->getEnclosure());
         // Re -dump top file from in memory image
         foreach ($this->inMemoryImage as $newLine) {
             foreach ($this->knownResultHeaders as $header) {
                 // The new header was not present for this line
                 if (!isset($newLine[$header])) {
                     // Set to empty so fputcsv will generate empty columns
                     $newLine[$header] = '';
                 }
             }
             ksort($newLine);
             fputcsv($this->file, $newLine, $subject->getDelimiter(), $subject->getEnclosure());
         }
     } else {
         ksort($newLine);
         fputcsv($this->file, $newLine, $subject->getDelimiter(), $subject->getEnclosure());
     }
 }
開發者ID:be2bill,項目名稱:php-merchant-api,代碼行數:57,代碼來源:FileReport.php

示例2: update

 /**
  * (PHP 5 &gt;= 5.1.0)<br/>
  * Receive update from subject
  * @link http://php.net/manual/en/splobserver.update.php
  * @param SplSubject $subject <p>
  * The <b>SplSubject</b> notifying the observer of an update.
  * </p>
  * @return void
  */
 public function update(SplSubject $subject)
 {
     $line = $subject->getCurrentLine() + 1;
     $params = $subject->getCurrentTransactionParameters();
     $result = $subject->getCurrentTransactionResult();
     $output = "Line {$line}";
     if (isset($params['ORDERID'])) {
         $output .= " (ORDERID={$params['ORDERID']})";
     }
     $output .= ' :';
     if (isset($result['EXECCODE'])) {
         $output .= " EXECCODE={$result['EXECCODE']}";
     }
     if (isset($result['MESSAGE'])) {
         $output .= " MESSAGE={$result['MESSAGE']}";
     }
     if (isset($result['TRANSACTIONID'])) {
         $output .= " TRANSACTIONID={$result['TRANSACTIONID']}";
     }
     $output .= "\n";
     echo $output;
 }
開發者ID:ramzes13,項目名稱:php-merchant-api,代碼行數:31,代碼來源:Debug.php


注:本文中的SplSubject::getCurrentTransactionResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。