复杂 PARSE.com 问题!使用多维数组查询数据并导出为 CSV

COMPLEX PARSE.com ISSUE! Query data and export into CSV with a multi dimensional array

我在将数组导入 CSV 文件时遇到问题,我现在可以将输出导入 CSV 文件,但它只会将以下内容打印到 CSV 文件中:

objectId    createdAt
Array   Array
Array   Array
Array   Array
Array   Array
Array   Array
Array   Array
Array   Array

我相信这是因为我需要展平数组,但我不知道该怎么做,我几乎在学习如何使用数组 & parse.com,我但是对PHP有很好的了解,我的代码如下:

$query = new ParseQuery("Counts");

 $results = $query->find();
 for ($i = 0; $i < count($results); $i++) 

 {    
    $detail=array();
    $object = $results[$i];

    $detail['objectId'][$i] = $object->getObjectId();
    $detail['createdAt'][$i] = $object->getCreatedAt();
  //  print_r($detail);
    $response[]=$detail;

 }


$output = fopen('php://output', 'w');
header("Content-Type:application/csv"); 
header("Content-Disposition:attachment;filename=dboutput.csv"); 
fputcsv($output, array('objectId','createdAt'));
foreach ($response as $fields) {
    fputcsv($output, $detail);
}
fclose($output);

我需要它来输出存储的信息,而不是输出数组,这些信息存储在我的 parse.com 数据库中(createdAt = date & objectId = string)。

如果它有助于数组如下所示:

数组 ( [日期] => 数组 ( [0] => eGocH6OznC )

[createdAt] => Array
    (
        [0] => DateTime Object
            (
                [date] => 2015-12-11 23:02:03.968000
                [timezone_type] => 2
                [timezone] => Z
            )

    )

) 大批 ( [日期] => 数组 ( [1] => P3uhKFzpsq )

[createdAt] => Array
    (
        [1] => DateTime Object
            (
                [date] => 2015-12-11 23:16:55.633000
                [timezone_type] => 2
                [timezone] => Z
            )

    )

)

我只需要将日期值和 objectId 值放入 CSV 文件的 2 列中。

非常感谢对此的任何指导。

执行此操作的正确代码是:

$query = new ParseQuery("Counts");

$results = $query->find();
$detail=array();
for ($i = 0; $i < count($results); $i++)

{

$object = $results[$i];

$detail[$i]['objectId'] = $object->getObjectId();
$detail[$i]['createdAt'] = $object->getCreatedAt()->format('Y-m-d H:i:s');

}


$output = fopen('php://output', 'w');
header("Content-Type:application/csv");
header("Content-Disposition:attachment;filename=dboutput.csv");
fputcsv($output, array('objectId','createdAt'));
foreach ($detail as $fields) {
fputcsv($output, $fields);
}
fclose($output);

?>