Welcome Guest, Not a member yet? Register   Sign In
too many rows breaking download
#1

[eluser]alberto24[/eluser]
Hi - I am having a problem with one of my customers - they have about 5,000 rows in the database and when I try to run the code to create a file (csv), in firefox it immediately goes to a blank white page and in IE i get a 500 error. customers with lesser amounts of rows still work fine.

Any ideas on how to fix this so it works? Here's my code:

Code:
function itemscsvdownload()
    {
        gateKeeper( 1 );    

        $this->load->model( 'item_model' );
        $objitemInfo = $this->item_model->getByitem( $this->session->userdata( 'user_id' ));

        {
        $this->load->helper('download');
        $this->db->where('customer_id', $this->session->userdata( 'user_id' ));
        $result = $this->db->get('itemdb');

        $name = 'items.csv';

        $data = '"item","iteminfo","iteminfo1"' . "\r\n";
        foreach ($result->result() as $thing)
        {
            $data .= chr(34) . $thing->item . chr(34). ",";
            $data .= chr(34) . $thing->iteminfo . chr(34). ",";
            $data .= chr(34) . $thing->iteminfo1 . chr(34). ",";            
        }
        force_download($name, $data);
    }
        }

I removed some of the other data bits just to make it clearer. Any help is very much appreciated.

Thanks!


Messages In This Thread
too many rows breaking download - by El Forum - 06-20-2009, 12:00 PM
too many rows breaking download - by El Forum - 06-20-2009, 12:07 PM
too many rows breaking download - by El Forum - 06-20-2009, 12:25 PM
too many rows breaking download - by El Forum - 06-20-2009, 01:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB