CodeIgniter Forums
Different column for csv_from_result function in written file? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Different column for csv_from_result function in written file? (/showthread.php?tid=53665)



Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]jpganz[/eluser]
Hi,

I am using csv_from_result to export my result to a cvs file, still I am having a problem with it, I wanna export the results separated each column on my cvs per field returned from my DB,

I checked this post http://ellislab.com/forums/viewthread/214852/ and I tried the /t, but still no results, any other has this problem? I am using CI 2.1

here is my code

Code:
$this->load->dbutil();
$this->db->select('profile.profile_username,..... other fields');
$this->db->from('profile');
$this->db->join('client', 'client.id_profile = profile.id_profile', 'left');
$query = $this->db->get();
$enclosure = '';
$delimiter = "/t";
$newline = "\r\n";
$queryreturn = $this->dbutil->csv_from_result($query,$delimiter,$newline,$enclosure);

Any help would be appreciated.
Thanks


Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]CroNiX[/eluser]
I believe that should be a forward slash. \t is tab, not /t. Just like \r\n is linebreak/return.


Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]jpganz[/eluser]
Thanks, I tried with "\t" too, but didnt work...


Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]CroNiX[/eluser]
What is it doing then? What's the output?


Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]jpganz[/eluser]
with “\t” nothing happends, like if it wouldnt exist.. not even an space, if is "/t" the /t is printed in the doc.


Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]CroNiX[/eluser]
What happens if you just use the default values, which would be a comma for the delimiter?

Code:
$queryreturn = $this->dbutil->csv_from_result($query);



Different column for csv_from_result function in written file? - El Forum - 08-02-2012

[eluser]jpganz[/eluser]
with the comma it only shows the comma... it prints it (the comma was the first value I tried but didnt work)