当前位置: 首页>>代码示例>>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;未经允许,请勿转载。