2016-04-13 3 views
0

Ich versuche, CSV in Codeigniter statischen Wert hinzufügen ich bin Abfrage von der Datenbank, aber ich muss einen statischen Wert in CSV hinzufügen ist es möglich, hinzuzufügen?Wie statische Wert zu CSV in coderigniter hinzufügen

$searchtimesheet = $this->db->query('SELECT ohrm_project.name AS ohrm_projectname, TIME_FORMAT(SEC_TO_TIME(ohrm_timesheet_item.duration),"%Hh %im") as duration ,ohrm_timesheet_item.date AS date,concat(hs_hr_employee.emp_firstname," ",hs_hr_employee.emp_middle_name," ", hs_hr_employee.emp_lastname) as employeename FROM ohrm_project,ohrm_timesheet_item,hs_hr_employee WHERE ohrm_timesheet_item.employee_id=hs_hr_employee.employee_id AND ohrm_timesheet_item.project_id=ohrm_project.project_id AND ohrm_project.project_id='.$projectid.' AND ohrm_timesheet_item.date BETWEEN '.$todate1.' AND '.$fromdate1.''); 
     $this->load->dbutil(); 
$this->load->helper('download'); 
$this->load->helper('file'); 
$delimiter = ","; 
$newline = "\r\n"; 
$filename = 'projectimesheet.csv'; 
if($searchtimesheet->num_rows() >0) 
{ 
$totalduration1=$totalduration; //i want to append this static value to $this->dbutil->csv_from_result 
    echo $data = $this->dbutil->csv_from_result($searchtimesheet,$delimiter, $newline); 
    exit; 
    force_download($filename, $data); 

} 

Antwort

0

Sie können die $ Gesamtdauer Variable Wert auf das Ergebnis wie folgt anhängen:

echo $this->dbutil->csv_from_result($searchtimesheet, $delimiter, $newline) . $totalduration; 

Anmerkung: Gesamtdauer $ variable gleiche CSV-Datenkette als im Ergebnis enthalten sollte gültige CSV zu erhalten.