我是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有一个单击功能,允许您从表中获取数据,但是我需要在我的网站上构建一个功能,以便客户可以使用它。
有没有人有任何想法?
更新:
这是输出的一个snippit(它输出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 )
答案 0 :(得分:1)
我不确定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);
?>