We have our csv text ready to export. The first thing we'll do is create a temporary file we can use when we create the zip file. I'm going to do something a little different here. I've had some problems trying to push files that contain the directory path. To overcome that, we'll just change directories using chdir(). As we work with the files, we'll leave out the path.
When we call the function we'll pass it both the sql statement and a filename without the extension. Normally, I just use the table name. But if we're working with multiple tables, we need to come up with something else.
Let's save our temporary file setting up some paths and common variables as we go:
Now we'll create the zip file using pclZip:
Pushing the content
We're almost done. All we need to do now is push the zip file to the browser. We'll do that in the next section.
Click the Next Page link below to continue your journey.
Next Page: CSV Export Class - Pushing the content