Ich habe zwei Tabellen in der DB. One ist Lead und andere Lead Note .. Lead und Lead Note haben Fremdschlüssel Beziehung .. Ich möchte eine CSV generieren, so dass es eine Lead-Spalte haben dann alle Hinweise zu diesem Lead ..Generiere CSV mit 2 Tabellen mit Codigniter
Here is what I need Mein aktueller Code ist
$all_leads = '';
$name = 'leads-'.date('d-m-Y').'.csv';
$this->load->dbutil();
$this->db->select("lead_id as Lead ID,business_name as Business,contact_name as First Name,contact_name_last as Last Name,work_email as Email,contact_email as Personal Email,work_number as Work Number,cell_no as Cell No,city as City,state as State,zip as Zip,date_added as Date Added,IF(label_type <> 0,'Important',' ') as Label, companies.company_name as company name");
$this->db->from('leads');
$this->db->join('companies', 'companies.id = leads.company');
$leads = $this->db->get();
$num_rows = $leads->num_rows();
$all_leads= $this->dbutil->csv_from_result($leads);
write_file($this->file_path . '/'.$name,$all_leads);
$data = file_get_contents($this->file_path . '/'.$name);
force_download($name, $data);
delete_files($this->file_path . '/'.$name);`
Dies ist nur ein Tabellendaten einsehen. Wie hole ich beide Tabellendaten für diesen Code? –
siehe die bearbeitete Antwort –
war es hilfreich? –