protected function storeReportData($eventID = '') { $fileDir = SITE_PATH_REPORTS; $fileName = ''; $dataGetter = new RegSummaryTools(); $fileName = modulecim_reg::AIA_CSV_FILE_NAME; $fileData = $dataGetter->getCSVforAIAEvent($eventID); // BEGIN: CODE MODIFIED FROM 'fwrite()' IN PHP.NET DOCUMENTATION >>> TODO?: write each record as it is read // Let's make sure the file exists and is writable first. //if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!($handle = fopen($fileDir . $fileName, 'w'))) { echo "Cannot open file ({$fileDir}.{$fileName})"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $fileData) === FALSE) { echo "Cannot write to file ({$fileDir}.{$fileName})"; exit; } //echo "Success, wrote ($fileData) to file ($fileName)"; fclose($handle); //} else { // echo "The file $filename is not writable"; //} return $fileName; }