额外的字段没有被打印

下午好

我正在使用CakePHP为判断系统添加更多的function和function。 我已经寻找可能的解决scheme,并尝试自己解决问题,但我仍然无法找出我的代码或数据库有什么问题。 我想添加一个额外的领域,从我的数据库中输出一个Excel文件,但不打印。 Jcategory填入数据库,但不会打印在CSV文件上。 所有其他领域填写在Excel文件除了我的加法(Jcategory)。

public function data2() { $this->autoLayout = $this->autoRender = false; ini_set('max_execution_time', 600); //increase max_execution_time to 10 min if data set is very large //create a file $filename = "export_".date("Ymd").".csv"; $csv_file = fopen('php://output', 'w'); header('Content-type: application/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); //ALWAYS NEED RESULT $results = $this->Post->find('all'); //$results = $this->Poster->find('all'); // The column headings of your .csv file $header_row = array("id","poster_id","criteria1","criteria2","criteria3","criteria4","criteria5","criteria6","criteria7","criteria8","criteria9","criteria10","Jcategory","Test","Score","Author","category"); fputcsv($csv_file,$header_row,',','"'); // Each iteration of this while loop will be a row in your .csv file where each field corresponds to the heading of the column foreach($results as $result) { $authors = ''; $authors = substr($authors,0,sizeof($authors)-3); $row = array( $result['Post']['id'], $result['Post']['poster_id'], $result['Post']['criteria1'], $result['Post']['criteria2'], $result['Post']['criteria3'], $result['Post']['criteria4'], $result['Post']['criteria5'], $result['Post']['criteria6'], $result['Post']['criteria7'], $result['Post']['criteria8'], $result['Post']['criteria9'], $result['Post']['criteria10'], $result['Post']['comments'], $result['Post']['jcategory'], //This is not being printed in the CSV File //Results are here at the bottom ($result['Post']['criteria1'])+($result['Post']['criteria2'])+($result['Post']['criteria3'])+($result['Post']['criteria4'])+($result['Post']['criteria5'])+($result['Post']['criteria6'])+($result['Post']['criteria7'])+($result['Post']['criteria8'])+($result['Post']['criteria9'])+($result['Post']['criteria10']), $result['poster']['author'], $result['poster']['category'], ); foreach($result['Author'] as $author){ array_push($row, $author['id']); array_push($row, $author['middle']); array_push($row, $author['last']); array_push($row, $author['email']); array_push($row, $author['institution']); array_push($row, $author['department']); array_push($row, $author['type']); } fputcsv($csv_file,$row,',','"'); } fclose($csv_file); }