0

I am currently looking at exporting member data periodically and submitting this to the server for the client to retrieve on a regular basis.

I have been looking at various modules which create a CSV file such as AJW Export. I was then going to visit this URL automatically using the Automatee plugin however I can only get the CSV file available for download in the browser, not to the server.

Any advice appreciated.

Many thanks Ben

----------- EDIT -------------

I have been looking through the forums and found some good examples, however when I implement these into my plugin file I just receive server errors. I'm working on MAMP but can't figure out what is causing the issue, when I replace the code below with some default text values, the plugin works.

function Export_to_server() {
   $this->load->helper('file');
   $this->load->dbutil();

   $delimiter = ",";
   $newline = "\r\n";
   $query = $this->db->query("SELECT * FROM stations");    
   $csv = $this->dbutil->csv_from_result($query,$delimiter,$newline);

   if ( !write_file('./uploads/', $csv))

   {
      echo 'Unable to write the file';
   }
   else
   {
     echo 'File written!';
   } 

I have also attempted

function Export_to_server() {
   $this->EE->load->helper('file');
   $this->EE->load->dbutil();

   $delimiter = ",";
   $newline = "\r\n";
   $query = $this->EE->db->query("SELECT * FROM stations");    
   $csv = $this-EE>->dbutil->csv_from_result($query,$delimiter,$newline);

   if ( !write_file('./uploads/', $csv))

    {
      echo 'Unable to write the file';
     }
    else
     {
       echo 'File written!';
     } 

Forgive my noobie plugin skills, this is the first attempt at developing one for me!

4
  • Would you like exported CSV be saved within a directory of server? If so AJW Export either results exported data to browser or download it to file. Apr 30 '13 at 17:45
  • Yes I would like to save the file within a directory of the server. The only reason is the client would like this backed up regularly, where they can retrieve each export for their records.
    – Ben
    May 1 '13 at 8:00
  • well, you would need to develop a small plugin which can perform same for exporting CSV (like AJW Export) and put csv within specified directory. May 1 '13 at 8:39
  • I have updated my question as I couldn't fit it into a comment :). Thanks for help so far!
    – Ben
    May 1 '13 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.