Welcome Guest, Not a member yet? Register   Sign In
Help with CSV export Query (using join)
#1

[eluser]snowstar[/eluser]
Hi All,

not sure how to query my db to get the right result

my controller

Code:
function export_multimedia()
{
  $this->load->dbutil();
  
  $delimiter = ",";
  $newline = "\r\n";
  
  $this->db->join('bandinfo', 'bandinfo.uniqueid = multimedia.uniqueid');
  $this->db->select('*');
  $this->db->from('multimedia');

  $query = $this->db->get();

  $export = $this->dbutil->csv_from_result($query, $delimiter, $newline);

  $this->load->helper('file');
  write_file('/export/mybackup.csv', $export);

  $this->load->helper('download');
  force_download('mybackup.csv', $export);
}
Basically i need to match the uniqueid field in bandinfo(table) to multimedia(table) bandname field where bandinfo.uniqueid and multimedia.uniqueid match.

IE:
Multimedia table:

Unique id Food Color
22 Chicken Green
24 Pork Yellow

Bandinfo
Uniqueid bandname
22 something
23 something else


CSV to export as:

Unique id bandname food color
22 something chicken green



Any help is much appreciated
#2

[eluser]porquero[/eluser]
Try this library:

http://code.google.com/p/parsecsv-for-php/
#3

[eluser]snowstar[/eluser]
Thanks for the reply, I'll check it out.

I thought i was going wrong with the query not the method in which i out put the data. The Data output comes out fine, its just data it self which im trying to manipulate




Theme © iAndrew 2016 - Forum software by © MyBB