gpt4 book ai didi

PHP Parse.com 将表格导出为 CSV 文件

转载 作者:搜寻专家 更新时间:2023-10-30 23:41:39 25 4
gpt4 key购买 nike

我是 Parse.com 的新手,正在学习,有人知道是否可以从 Parse.com 查询数据,然后使用 PHP 将其导出到 CSV 文件中吗?

我的 parse.com 查询如下:

$query = new ParseQuery("Counter");
$query->equalTo("user", $currentUser);
$result = $query->find();
print_r($result);

这为我提供了所有数据,我需要将所有这些数据放入一个 csv 文件中。

我知道 parse.com 有一个一键式功能,可以让您从表格中获取数据,但是我需要在我的网站上构建一个功能来执行此操作,以便客户可以使用它。

有没有人有什么想法?

更新:

这是输出的一个片段(它输出了 159 条记录,所以我只包括了前几条)。

Array ( [0] => Parse\ParseObject Object ( [serverData:protected] => Array ( [covers] => Array ( [0] => 1 ) ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [covers] => Array ( [0] => 1 ) ) [dataAvailability:Parse\ParseObject:private] => Array ( [covers] => 1 ) [className:Parse\ParseObject:private] => Covers [objectId:Parse\ParseObject:private] => l6rKi7qpFX [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2015-12-12 00:40:58.178000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2015-12-12 00:40:58.178000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\ParseObject:private] => 1 ) [1] => Parse\ParseObject Object ( [serverData:protected] => Array ( [covers] => Array ( [0] => 1 ) ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [covers] => Array ( [0] => 1 ) ) [dataAvailability:Parse\ParseObject:private] => Array ( [covers] => 1 ) [className:Parse\ParseObject:private] => Covers [objectId:Parse\ParseObject:private] => pKAhO2o9Yp [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2015-12-12 00:40:57.309000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2015-12-12 00:40:57.309000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\ParseObject:private] => 1 ) [2] => Parse\ParseObject Object ( [serverData:protected] => Array ( [covers] => Array ( [0] => 1 ) ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [covers] => Array ( [0] => 1 ) ) [dataAvailability:Parse\ParseObject:private] => Array ( [covers] => 1 ) [className:Parse\ParseObject:private] => Covers [objectId:Parse\ParseObject:private] => 6q17n3FFyX [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2015-12-12 00:40:56.453000 [timezone_type] => 2 [timezone] => Z ) 

最佳答案

我不确定 fputcsv会有所帮助,但您可以尝试一下

<?php

$query = new ParseQuery("Counter");
$query->equalTo("user", $currentUser);
$result = $query->find();
//print_r($result);

$fp = fopen('file.csv', 'w');

foreach ($result as $fields) {
fputcsv($fp, $fields);
}

fclose($fp);
?>

关于PHP Parse.com 将表格导出为 CSV 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34405417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com