当前位置: 首页>>代码示例>>PHP>>正文


PHP Writer::insertAll方法代码示例

本文整理汇总了PHP中League\Csv\Writer::insertAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Writer::insertAll方法的具体用法?PHP Writer::insertAll怎么用?PHP Writer::insertAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Csv\Writer的用法示例。


在下文中一共展示了Writer::insertAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * Generate a spreadsheet by transforming 3D data into 2D data.
  *
  * @param array $filters (optional)
  * @return League\Csv\Writer
  */
 public function generate(array $filters = [])
 {
     // Query the repository for filtered set of objects to export
     $objects = $this->query($filters);
     // Insert headers
     $this->data->insertOne($this->getHeaders());
     // Add objects as rows
     if ($objects) {
         // Transform a 3D object into a 2D row
         $objects->transform([$this, 'transform']);
         // Insert all the objects as rows
         $this->data->insertAll($objects->toArray());
     }
     return $this->data;
 }
开发者ID:esensi,项目名称:core,代码行数:21,代码来源:SpreadsheetExporter.php

示例2: sprintf

    echo 'Error: ' . $e->getMessage();
    exit;
}
echo PHP_EOL;
echo sprintf('%s open and %s closed issues pulled…', (string) count($issues['open']), (string) count($issues['closed']));
// Set up the header rows for the CSV
$toWrite = [['url', 'number', 'title', 'status', 'assignee', 'milestone', 'created_at', 'updated_at', 'body']];
$prCount = 0;
// Set up the data rows for the CSV
foreach ($issues as $states) {
    foreach ($states as $issue) {
        // Strip out pull requests
        if (strpos($issue['html_url'], '/pull/')) {
            ++$prCount;
            continue;
        }
        $assignee = $issue['assignee'] == null ? '' : $issue['assignee']['login'];
        $milestone = $issue['milestone'] == null ? '' : $issue['milestone']['number'] . ': ' . $issue['milestone']['title'];
        $toWrite[] = [$issue['html_url'], $issue['number'], $issue['title'], $issue['state'], $assignee, $milestone, $issue['created_at'], $issue['updated_at'], $issue['body']];
    }
}
echo PHP_EOL;
echo sprintf('Stripping out %s pull requests…', (string) $prCount);
echo PHP_EOL;
echo 'Writing to CSV…';
// Write the array to the CSV file
$writer = new Writer(sprintf('%s.csv', $repo->owner . '_' . $repo->name), 'ab+');
$writer->setNullHandlingMode(Writer::NULL_AS_EMPTY);
$writer->insertAll($toWrite);
echo PHP_EOL;
echo sprintf('Done! CSV file is %s.csv', $repo->name);
开发者ID:bcooney,项目名称:github-issues,代码行数:31,代码来源:GithubIssues.php


注:本文中的League\Csv\Writer::insertAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。